Ghost/ghost/admin/app/serializers/user.js

30 lines
1004 B
JavaScript
Raw Normal View History

2015-02-13 07:22:32 +03:00
import Ember from 'ember';
import ApplicationSerializer from 'ghost-admin/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);
}
});