Skip to content

Commit 20feadc

Browse files
author
Lee Richmond
committed
Move jsonapiType() to model method
1 parent ee6259b commit 20feadc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

addon/mixins/model.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ export default Ember.Mixin.create({
4545
this.set('_markedForDestruction', true);
4646
},
4747

48+
jsonapiType() {
49+
return this.store
50+
.adapterFor(this.constructor.modelName)
51+
.pathForType(this.constructor.modelName);
52+
},
53+
4854
// Blank out all relations after saving
4955
// We will use the server response includes to 'reset'
5056
// these relations

addon/mixins/nested-relations.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@ const attributesFor = function(record) {
5050
return attrs;
5151
};
5252

53-
const jsonapiType = function(record) {
54-
return record.store
55-
.adapterFor(record.constructor.modelName)
56-
.pathForType(record.constructor.modelName);
57-
};
58-
5953
const jsonapiPayload = function(record) {
6054
let attributes = attributesFor(record);
6155

62-
let payload = { type: jsonapiType(record) };
56+
let payload = { type: record.jsonapiType() };
6357

6458
if (isPresentObject(attributes)) {
6559
payload.attributes = attributes;

0 commit comments

Comments
 (0)