Skip to content

Commit

Permalink
Refactor serializer to native classes
Browse files Browse the repository at this point in the history
  • Loading branch information
fsmanuel committed Sep 4, 2022
1 parent 8517ff7 commit 82fbbad
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions addon/serializers/serializer.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -43,7 +43,7 @@ export default JSONAPISerializer.extend({
json.relationships[payloadKey] = { data };
}
}
},
}

_fixSerializeHasMany(snapshot, json, relationship) {
let key = relationship.key;
Expand All @@ -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] = {
Expand All @@ -78,5 +78,5 @@ export default JSONAPISerializer.extend({
json.relationships[payloadKey] = { data };
}
}
},
});
}
}

0 comments on commit 82fbbad

Please sign in to comment.