Skip to content

Commit

Permalink
Add errors#isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
brettshollenberger committed Jan 7, 2014
1 parent 34098ae commit db2c7a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ActiveResource",
"version": "0.2.5",
"version": "0.2.6",
"authors": [
"Brett Shollenberger <brett.shollenberger@gmail.com>"
],
Expand Down
7 changes: 7 additions & 0 deletions lib/angular-resource/base/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ angular
}
};

// function isEmpty()
//
// True/false cache is empty
this.isEmpty = function() {
return Object.keys(this).length == 0;
};

// function where(terms)
//
// @param {terms} - Search terms used to find instances in the cache
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ActiveResource",
"version": "0.2.5",
"version": "0.2.6",
"description": "RESTful resource modeling",
"main": "index.js",
"author": "Brett Shollenberger <brett@facultycreative.com>",
Expand Down
4 changes: 4 additions & 0 deletions spec/angular-resource/active-resource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ describe('ActiveResource', function() {
expect(System.cached).toBeDefined();
});

it('has #isEmpty method to tell you whether or not the cache is empty', function() {
expect(System.cached.isEmpty()).toBe(false);
});

it('adds new instances to the cache', function() {
expect(System.cached[1]).toBe(system);
});
Expand Down

0 comments on commit db2c7a8

Please sign in to comment.