Skip to content

Commit

Permalink
Merge pull request emberjs#1286 from thomasboyt/metadataFor
Browse files Browse the repository at this point in the history
Add metadataFor
  • Loading branch information
wycats committed Sep 12, 2013
2 parents ddaa5fa + 1421110 commit 8c89df2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/ember-data/lib/system/store.js
Expand Up @@ -781,6 +781,18 @@ DS.Store = Ember.Object.extend(DS._Mappable, {
return !get(this.recordForId(type, id), 'isEmpty');
},

/**
This method returns the metadata for a specific type.
@method metadataFor
@param {string} type
@return {object}
*/
metadataFor: function(type) {
type = this.modelFor(type);
return this.typeMapFor(type).metadata;
},

// ............
// . UPDATING .
// ............
Expand Down
Expand Up @@ -504,6 +504,14 @@ test("findAll - since token is passed to the adapter", function() {
}));
});

test("metadata is accessible", function() {
ajaxResponse({ meta: { offset: 5 }, posts: [{id: 1, name: "Rails is very expensive sushi"}] });

store.findAll('post').then(async(function(posts) {
equal(store.metadataFor('post').offset, 5, "Metadata can be accessed with metadataFor.");
}));
});

test("findQuery - returning an array populates the array", function() {
ajaxResponse({ posts: [{ id: 1, name: "Rails is omakase" }, { id: 2, name: "The Parley Letter" }] });

Expand Down

0 comments on commit 8c89df2

Please sign in to comment.