Skip to content

Commit

Permalink
address code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Dec 6, 2016
1 parent 120df47 commit 1f36619
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
28 changes: 13 additions & 15 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ Store = Service.extend({
});
this._pendingSave = [];
this._pushedInternalModels = [];
this._relationshipFlush = null;

this._instanceCache = new ContainerInstanceCache(getOwner(this), this);

//Used to keep track of all the find requests that need to be coalesced
Expand Down Expand Up @@ -1867,9 +1869,6 @@ Store = Service.extend({
resolver.resolve(_commit(adapter, this, operation, snapshot));
}

pending.forEach((pendingItem) => {

});
},

/**
Expand Down Expand Up @@ -2268,16 +2267,17 @@ Store = Service.extend({
},

/*
Push some data into the store, without creating materialized records.
Push some data in the form of a json-api document into the store,
without creating materialized records.
@method _push
@private
@param {Object} apiDoc
@param {Object} jsonApiDoc
@return {DS.InternalModel|Array<DS.InternalModel>} pushed InternalModel(s)
*/
_push(apiDoc) {
_push(jsonApiDoc) {
let token = heimdall.start('store._push');
let included = apiDoc.included;
let included = jsonApiDoc.included;
let i, length;

if (included) {
Expand All @@ -2286,25 +2286,25 @@ Store = Service.extend({
}
}

if (Array.isArray(apiDoc.data)) {
length = apiDoc.data.length;
if (Array.isArray(jsonApiDoc.data)) {
length = jsonApiDoc.data.length;
let internalModels = new Array(length);

for (i = 0; i < length; i++) {
internalModels[i] = this._pushInternalModel(apiDoc.data[i]);
internalModels[i] = this._pushInternalModel(jsonApiDoc.data[i]);
}
heimdall.stop(token);
return internalModels;
}

if (apiDoc.data === null) {
if (jsonApiDoc.data === null) {
heimdall.stop(token);
return null;
}

assert(`Expected an object in the 'data' property in a call to 'push' for ${apiDoc.type}, but was ${typeOf(apiDoc.data)}`, typeOf(apiDoc.data) === 'object');
assert(`Expected an object in the 'data' property in a call to 'push' for ${jsonApiDoc.type}, but was ${typeOf(jsonApiDoc.data)}`, typeOf(jsonApiDoc.data) === 'object');

let internalModel = this._pushInternalModel(apiDoc.data);
let internalModel = this._pushInternalModel(jsonApiDoc.data);

heimdall.stop(token);
return internalModel;
Expand All @@ -2314,8 +2314,6 @@ Store = Service.extend({
return !!getOwner(this)._lookupFactory(`model:${modelName}`);
},

_pushedInternalModels: null,
_relationshipFlush: null,
_pushInternalModel(data) {
heimdall.increment(_pushInternalModel);
let modelName = data.type;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/adapter/build-url-mixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ test('buildURL - buildURL takes the records from findMany', function(assert) {
}
}
});
post.get('comments').then(assert.wait(function(rel) {
post.get('comments').then(assert.wait(function(post) {
assert.equal(passedUrl, "/posts/2/comments/");
}));
});
Expand Down

0 comments on commit 1f36619

Please sign in to comment.