This commit is contained in:
Matthew Dillon 2015-11-12 05:54:18 -07:00
parent aeb3206fd9
commit 21e0e6c624
10 changed files with 112 additions and 87 deletions

View file

@ -1,19 +1,22 @@
import DS from 'ember-data';
import Ember from 'ember';
export default DS.RESTSerializer.extend({
const { RESTSerializer } = DS;
const { isNone } = Ember;
export default RESTSerializer.extend({
isNewSerializerAPI: true,
serializeBelongsTo: function(snapshot, json, relationship) {
var key = relationship.key;
var belongsTo = snapshot.belongsTo(key);
let key = relationship.key;
const belongsTo = snapshot.belongsTo(key);
key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key;
json[key] = Ember.isNone(belongsTo) ? belongsTo : +belongsTo.record.id;
json[key] = isNone(belongsTo) ? belongsTo : +belongsTo.record.id;
},
serializeHasMany: function(snapshot, json, relationship) {
var key = relationship.key;
var hasMany = snapshot.hasMany(key);
let key = relationship.key;
const hasMany = snapshot.hasMany(key);
key = this.keyForRelationship ? this.keyForRelationship(key, "hasMany", "serialize") : key;
json[key] = [];