Skip to content

Commit

Permalink
chore: merge in upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-north committed Nov 1, 2018
1 parent fc92daa commit 08df6a7
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions tests/dummy/app/models/fruit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ function mergeAttributes(attributes) {
return payload;
}

// This is an example of how to extract JSON API responses and push
// them into the store.
// TODO extract and export as part of this addon
function serializeAndPush(response) {
const recordClass = this.constructor;
const modelName = recordClass.modelName;
const { store } = this;
const serializer = store.serializerFor(modelName);
const normalized = isArray(response.data) ? serializer.normalizeArrayResponse(store, recordClass, response) :
serializer.normalizeSingleResponse(store, recordClass, response);
return this.store.push(normalized);
}

export default Model.extend({
name: attr('string'),
ripen: memberAction({ path: 'doRipen' }),
Expand All @@ -39,6 +26,7 @@ export default Model.extend({
eatAll: collectionAction({
path: 'doEatAll',
before: mergeAttributes,
after: serializeAndPush })
after: serializeAndPush
})
});
// END-SNIPPET

0 comments on commit 08df6a7

Please sign in to comment.