Permalink
Browse files

Make collections Enumberable

  • Loading branch information...
1 parent 99058f7 commit cfd59b019cf16d71825d8e953cb65bd3c3d109cb @vesan committed Jul 19, 2012
Showing with 10 additions and 2 deletions.
  1. +4 −2 README.md
  2. +2 −0 lib/kippt/collection.rb
  3. +4 −0 spec/spec_helper.rb
View
@@ -73,7 +73,7 @@ Get all the lists:
```ruby
client = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
-lists = client.lists # Returns Kippt::ListCollection
+lists = client.lists.all # Returns Kippt::ListCollection
```
Get single list:
@@ -89,9 +89,11 @@ list = client.lists[list_id] # Returns Kippt::ListItem
```ruby
client = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
-clips = client.clips # Returns Kippt::ClipCollection
+clips = client.clips.all # Returns Kippt::ClipCollection
```
+Both ListCollection and ClipCollection are Enumerable.
+
### Pagination
View
@@ -1,4 +1,6 @@
module Kippt::Collection
+ include Enumerable
+
attr_reader :total_count, :limit, :offset
def initialize(data, collection_resource = nil)
View
@@ -96,6 +96,10 @@ def fixture(file)
end
shared_examples_for "collection" do
+ it "is Enumberable" do
+ subject.should be_a(Enumerable)
+ end
+
describe "#total_count" do
it "returns total count of resources" do
subject.total_count.should eq data["meta"]["total_count"]

0 comments on commit cfd59b0

Please sign in to comment.