From 82fbbad8eb14cdc5f58232c9281a92836b5ad87e Mon Sep 17 00:00:00 2001 From: Manuel Wiedenmann Date: Sun, 4 Sep 2022 23:27:04 +0200 Subject: [PATCH] Refactor serializer to native classes --- addon/serializers/serializer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addon/serializers/serializer.js b/addon/serializers/serializer.js index df865ff..da40a61 100644 --- a/addon/serializers/serializer.js +++ b/addon/serializers/serializer.js @@ -1,17 +1,17 @@ import JSONAPISerializer from '@ember-data/serializer/json-api'; -export default JSONAPISerializer.extend({ +export default class Serializer extends JSONAPISerializer { shouldSerializeHasMany() { return true; - }, + } serializeBelongsTo() { this._fixSerializeBelongsTo(...arguments); - }, + } serializeHasMany() { this._fixSerializeHasMany(...arguments); - }, + } _fixSerializeBelongsTo(snapshot, json, relationship) { let key = relationship.key; @@ -43,7 +43,7 @@ export default JSONAPISerializer.extend({ json.relationships[payloadKey] = { data }; } } - }, + } _fixSerializeHasMany(snapshot, json, relationship) { let key = relationship.key; @@ -66,7 +66,7 @@ export default JSONAPISerializer.extend({ let data = new Array(nonNewHasMany.length); for (let i = 0; i < nonNewHasMany.length; i++) { - let item = hasMany[i]; + let item = nonNewHasMany[i]; let payloadType = this.payloadKeyFromModelName(item.modelName); data[i] = { @@ -78,5 +78,5 @@ export default JSONAPISerializer.extend({ json.relationships[payloadKey] = { data }; } } - }, -}); + } +}