Class: ScriptedClient::Collection
- Inherits:
-
ActiveResource::Collection
- Object
- ActiveResource::Collection
- ScriptedClient::Collection
- Defined in:
- lib/scripted_client/collection.rb
Instance Attribute Summary collapse
-
#next_page ⇒ Object
Returns the value of attribute next_page.
Instance Method Summary collapse
- #has_next? ⇒ Boolean
-
#initialize(parsed = {}) ⇒ Collection
constructor
A new instance of Collection.
- #next ⇒ Object
Constructor Details
#initialize(parsed = {}) ⇒ Collection
Returns a new instance of Collection.
6 7 8 9 10 |
# File 'lib/scripted_client/collection.rb', line 6 def initialize(parsed = {}) @elements = parsed['data'] paging = parsed['paging'] @next_page = paging['next_cursor'] if paging && paging['has_next'] end |
Instance Attribute Details
#next_page ⇒ Object
Returns the value of attribute next_page.
4 5 6 |
# File 'lib/scripted_client/collection.rb', line 4 def next_page @next_page end |
Instance Method Details
#has_next? ⇒ Boolean
19 20 21 |
# File 'lib/scripted_client/collection.rb', line 19 def has_next? next_page.present? end |
#next ⇒ Object
12 13 14 15 16 17 |
# File 'lib/scripted_client/collection.rb', line 12 def next fail 'No more pages' unless has_next? resource_class.all( params: original_params.merge(next_cursor: next_page) ) end |