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

introduce modelNameFromPayloadKey and deprecate typeForRoot #3034

Merged
merged 1 commit into from
May 16, 2015

Conversation

fivetanley
Copy link
Member

Introduced in this commit is payloadKeyFromModelName, which allows you
to specify the outgoing root key for a model name in the JSON payload.

For example:

RESTSerializer.extend({modelNameFromPayloadKey: underscore});
{
  "taco-party": { }
}

becomes

{
  "taco_party": {}
}

For symmetry, modelNameFromPayloadKey has been introduced to
look up the ember data record in the store given a JSON root
key. This used to be called pathForType, which has been deprecated.

Part of the refactor stuff covered in #2821 (comment)

@fivetanley fivetanley force-pushed the new-serialization-hooks branch from 05eba94 to bb50646 Compare April 29, 2015 22:45
@bmac
Copy link
Member

bmac commented May 1, 2015

Looks good to me. @igorT thoughts?

@fivetanley fivetanley force-pushed the new-serialization-hooks branch 2 times, most recently from e449546 to 60030a4 Compare May 4, 2015 19:08
@fivetanley fivetanley force-pushed the new-serialization-hooks branch 4 times, most recently from 2c979cf to 64a5ed4 Compare May 14, 2015 14:55

```js
App.ApplicationSerializer = DS.RESTSerializer.extend({
typeForRoot: function(root) {
modelNameFromPayloadKey: function(root) {
var camelized = Ember.String.camelize(root);
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure of the context in this transition doc, but this suggests returning modelName as non-dasherized. Is incorrect.

Introduced in this commit is payloadKeyFromModelName, which allows you
to specify the outgoing root key for a model name in the JSON payload.

For example:

```javascript
RESTSerializer.extend({modelNameFromPayloadKey: Ember.String.underscore});
```

```json
{
  "taco-party": { }
}
```

becomes

```json
{
  "taco_party"
}
```

For symmetry, modelNameFromPayloadKey has been introduced to
look up the ember data record in the store given a JSON root
key. This used to be called pathForType, which has been deprecated.
@fivetanley fivetanley force-pushed the new-serialization-hooks branch from 64a5ed4 to de43733 Compare May 16, 2015 16:36
mixonic added a commit that referenced this pull request May 16, 2015
introduce modelNameFromPayloadKey and deprecate typeForRoot
@mixonic mixonic merged commit 22b0576 into master May 16, 2015
@fivetanley fivetanley deleted the new-serialization-hooks branch May 16, 2015 17:58
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.

3 participants