mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
no issue - https://github.com/emberjs/data/releases/tag/v2.4.1 - https://github.com/emberjs/data/releases/tag/v2.4.2 - uses the new public import path for `EmbeddedRecordsMixin` (http://emberjs.com/blog/2016/03/13/ember-data-2-4-released.html#toc_importing-modules - note that the module naming there isn't quite right)
29 lines
998 B
JavaScript
29 lines
998 B
JavaScript
import Ember from 'ember';
|
|
import ApplicationSerializer from 'ghost/serializers/application';
|
|
import EmbeddedRecordsMixin from 'ember-data/serializers/embedded-records-mixin';
|
|
|
|
export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
|
|
attrs: {
|
|
roles: {embedded: 'always'}
|
|
},
|
|
|
|
extractSingle(store, primaryType, payload) {
|
|
let root = this.keyForAttribute(primaryType.modelName);
|
|
let pluralizedRoot = Ember.String.pluralize(primaryType.modelName);
|
|
|
|
payload[root] = payload[pluralizedRoot][0];
|
|
delete payload[pluralizedRoot];
|
|
|
|
return this._super(...arguments);
|
|
},
|
|
|
|
normalizeSingleResponse(store, primaryModelClass, payload) {
|
|
let root = this.keyForAttribute(primaryModelClass.modelName);
|
|
let pluralizedRoot = Ember.String.pluralize(primaryModelClass.modelName);
|
|
|
|
payload[root] = payload[pluralizedRoot][0];
|
|
delete payload[pluralizedRoot];
|
|
|
|
return this._super(...arguments);
|
|
}
|
|
});
|