Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass requestType to buildURL #2898

Merged
merged 1 commit into from
Mar 25, 2015
Merged

Conversation

amiel
Copy link
Contributor

@amiel amiel commented Mar 18, 2015

This is another step toward emberjs/rfcs#4.

Others have requested ways to handle different urls per request type (see #1078).

Once url-templates lands, most users extending BuildURLMixin will not need to handle
requestType explicitly, as it will be possible to define a template for each request type.

@igorT
Copy link
Member

igorT commented Mar 18, 2015

Can you rebase? Seems like it's not merging cleanly

@amiel amiel force-pushed the requestType-to-buildURL branch 2 times, most recently from d863109 to e3dfab8 Compare March 18, 2015 00:33
@amiel
Copy link
Contributor Author

amiel commented Mar 18, 2015

Rebased, sorry about that.

var data = {};
var serializer = store.serializerFor(type.typeKey);
var snapshot = record._createSnapshot();
var url = this.buildURL(type.typeKey, null, snapshot, 'createRecord');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code for createRecord pass 'create' to buildURL, but in this example it's 'createRecord', typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Which do you think it should be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to keep it consistent with the method names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll go with that.

I think I was thinking that the method names were an implementation detail, but I think the consistency would be worth it.

Thanks for your input :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've changed these all to match the original function name (createRecord, updateRecord, etc)


if (sinceToken) {
query = { since: sinceToken };
}

return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });
url = this.buildURL(type.typeKey, undefined, undefined, 'findAll');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these missing arguments be null instead of undefined? This will make it more consistent with https://github.com/emberjs/data/pull/2898/files#diff-24089ab4caa677e410cbc5c13588c012L533

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Good idea

@bmac
Copy link
Member

bmac commented Mar 22, 2015

👍

@bmac bmac modified the milestone: 1.0.0-beta.16 Mar 22, 2015
@amiel
Copy link
Contributor Author

amiel commented Mar 23, 2015

I've made changes suggested by @bmac, but I need to rebase again.

@amiel amiel force-pushed the requestType-to-buildURL branch 2 times, most recently from a9f8331 to 11b06f0 Compare March 23, 2015 20:37
This is another step toward emberjs/rfcs#4.

Once url-templates lands, most users extending BuildURLMixin will not need to handle
requestType explicitly, as it will be possible to define a template for each request type.

Also move buildURL specific RESTAdapter tests to a new file
@amiel amiel force-pushed the requestType-to-buildURL branch from 11b06f0 to ff35ee7 Compare March 24, 2015 03:58
@amiel
Copy link
Contributor Author

amiel commented Mar 24, 2015

@igorT this should be ready now.

bmac added a commit that referenced this pull request Mar 25, 2015
@bmac bmac merged commit e8ceeeb into emberjs:master Mar 25, 2015
@bmac
Copy link
Member

bmac commented Mar 25, 2015

Thanks @amiel!

@amiel amiel deleted the requestType-to-buildURL branch March 25, 2015 17:09
@amiel
Copy link
Contributor Author

amiel commented Mar 25, 2015

Thank you!

@igorT
Copy link
Member

igorT commented Mar 25, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants