Skip to content

introduce modelNameFromPayloadKey and deprecate typeForRoot - #3034

Merged
mixonic merged 1 commit into
masterfrom
new-serialization-hooks
May 16, 2015
Merged

introduce modelNameFromPayloadKey and deprecate typeForRoot#3034
mixonic merged 1 commit into
masterfrom
new-serialization-hooks

Conversation

@fivetanley

Copy link
Copy Markdown
Contributor

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

bmac commented May 1, 2015

Copy link
Copy Markdown
Contributor

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
Comment thread TRANSITION.md Outdated

Copy link
Copy Markdown
Contributor

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