Class: Kloudless::Collection
- Inherits:
-
Object
- Object
- Kloudless::Collection
- Includes:
- Enumerable
- Defined in:
- lib/kloudless/collection.rb
Instance Method Summary collapse
- #count ⇒ Object
- #each ⇒ Object
-
#initialize(model, json) ⇒ Collection
constructor
A new instance of Collection.
- #next_page ⇒ Object
- #objects ⇒ Object
- #page ⇒ Object
- #total ⇒ Object
Constructor Details
permalink #initialize(model, json) ⇒ Collection
Returns a new instance of Collection.
5 6 7 8 |
# File 'lib/kloudless/collection.rb', line 5 def initialize(model, json) @model = model @json = json end |
Instance Method Details
permalink #count ⇒ Object
[View source]
14 15 16 |
# File 'lib/kloudless/collection.rb', line 14 def count @json["count"] end |
permalink #each ⇒ Object
[View source]
30 31 32 33 34 |
# File 'lib/kloudless/collection.rb', line 30 def each @json["objects"].each do |attrs| yield @model.new(attrs) end end |
permalink #next_page ⇒ Object
[View source]
22 23 24 |
# File 'lib/kloudless/collection.rb', line 22 def next_page @json["next_page"] end |
permalink #objects ⇒ Object
[View source]
26 27 28 |
# File 'lib/kloudless/collection.rb', line 26 def objects @json["objects"] end |
permalink #page ⇒ Object
[View source]
18 19 20 |
# File 'lib/kloudless/collection.rb', line 18 def page @json["page"] end |
permalink #total ⇒ Object
[View source]
10 11 12 |
# File 'lib/kloudless/collection.rb', line 10 def total @json["total"] end |