Ghost/core/client/app/serializers/application.js
Kevin P. Kucharczyk 9eac05e082 Standardise client property names to camelCase
closes #6018
- added keyForAttribute method in application serializer
- override keyForAttribute in settings serializer to not apply camelCase/underscore conversion
- rename under_scored properties to camelCased
2016-01-23 19:12:22 +01:00

28 lines
667 B
JavaScript

import Ember from 'ember';
import RESTSerializer from 'ember-data/serializers/rest';
const {
decamelize
} = Ember.String;
export default RESTSerializer.extend({
serializeIntoHash(hash, type, record, options) {
// Our API expects an id on the posted object
options = options || {};
options.includeId = true;
// We have a plural root in the API
let root = Ember.String.pluralize(type.modelName);
let data = this.serialize(record, options);
// Don't ever pass uuid's
delete data.uuid;
hash[root] = [data];
},
keyForAttribute(attr) {
return decamelize(attr);
}
});