2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2016-01-12 19:23:01 +00:00
|
|
|
import RESTSerializer from 'ember-data/serializers/rest';
|
2015-10-28 11:36:45 +00:00
|
|
|
|
2016-01-23 19:12:22 +01:00
|
|
|
const {
|
|
|
|
decamelize
|
|
|
|
} = Ember.String;
|
|
|
|
|
2015-10-28 11:36:45 +00:00
|
|
|
export default RESTSerializer.extend({
|
|
|
|
serializeIntoHash(hash, type, record, options) {
|
2014-05-09 00:00:10 -05:00
|
|
|
// Our API expects an id on the posted object
|
|
|
|
options = options || {};
|
|
|
|
options.includeId = true;
|
|
|
|
|
|
|
|
// We have a plural root in the API
|
2015-10-28 11:36:45 +00:00
|
|
|
let root = Ember.String.pluralize(type.modelName);
|
|
|
|
let data = this.serialize(record, options);
|
2014-05-09 00:00:10 -05:00
|
|
|
|
|
|
|
// Don't ever pass uuid's
|
|
|
|
delete data.uuid;
|
|
|
|
|
|
|
|
hash[root] = [data];
|
2016-01-23 19:12:22 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
keyForAttribute(attr) {
|
|
|
|
return decamelize(attr);
|
2014-05-09 00:00:10 -05:00
|
|
|
}
|
2014-06-09 07:02:51 -04:00
|
|
|
});
|