From 37d7ca0029059002285993e4e16e91cc179fd0d4 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 9 Sep 2015 11:40:07 -0700 Subject: [PATCH] Application-wide serializer --- app/serializers/{strain.js => application.js} | 13 ++++++++++++- app/serializers/characteristic.js | 18 ------------------ 2 files changed, 12 insertions(+), 19 deletions(-) rename app/serializers/{strain.js => application.js} (57%) delete mode 100644 app/serializers/characteristic.js diff --git a/app/serializers/strain.js b/app/serializers/application.js similarity index 57% rename from app/serializers/strain.js rename to app/serializers/application.js index ddadf39..52f555e 100644 --- a/app/serializers/strain.js +++ b/app/serializers/application.js @@ -9,6 +9,17 @@ export default DS.RESTSerializer.extend({ var belongsTo = snapshot.belongsTo(key); key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key; json[key] = Ember.isNone(belongsTo) ? belongsTo : +belongsTo.record.id; - } + }, + + serializeHasMany: function(snapshot, json, relationship) { + var key = relationship.key; + var hasMany = snapshot.hasMany(key); + key = this.keyForRelationship ? this.keyForRelationship(key, "hasMany", "serialize") : key; + + json[key] = []; + hasMany.forEach((item) => { + json[key].push(+item.id); + }); + }, }); diff --git a/app/serializers/characteristic.js b/app/serializers/characteristic.js deleted file mode 100644 index 41ce180..0000000 --- a/app/serializers/characteristic.js +++ /dev/null @@ -1,18 +0,0 @@ -import DS from 'ember-data'; -import Ember from 'ember'; - -export default DS.RESTSerializer.extend({ - isNewSerializerAPI: true, - - serializeHasMany: function(snapshot, json, relationship) { - var key = relationship.key; - var hasMany = snapshot.hasMany(key); - key = this.keyForRelationship ? this.keyForRelationship(key, "hasMany", "serialize") : key; - - json[key] = []; - hasMany.forEach((item) => { - json[key].push(+item.get('id')); - }); - } - -});