2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
import DS from 'ember-data';
|
2014-07-21 01:48:24 +04:00
|
|
|
import ApplicationSerializer from 'ghost/serializers/application';
|
|
|
|
|
|
|
|
var UserSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
|
|
|
|
attrs: {
|
2014-10-25 01:09:50 +04:00
|
|
|
roles: {embedded: 'always'}
|
2014-07-21 01:48:24 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
extractSingle: function (store, primaryType, payload) {
|
2015-06-03 05:56:42 +03:00
|
|
|
var root = this.keyForAttribute(primaryType.modelName),
|
|
|
|
pluralizedRoot = Ember.String.pluralize(primaryType.modelName);
|
2014-07-21 01:48:24 +04:00
|
|
|
|
|
|
|
payload[root] = payload[pluralizedRoot][0];
|
|
|
|
delete payload[pluralizedRoot];
|
|
|
|
|
|
|
|
return this._super.apply(this, arguments);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default UserSerializer;
|