Class: Workable::Collection
- Inherits:
-
Object
- Object
- Workable::Collection
- Extended by:
- Forwardable
- Defined in:
- lib/workable/collection.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #fetch_next_page ⇒ Object
-
#initialize(data:, next_page_method:, transform_mapping:, root_key:, paging: nil) ⇒ Collection
constructor
A new instance of Collection.
- #next_page? ⇒ Boolean
Constructor Details
#initialize(data:, next_page_method:, transform_mapping:, root_key:, paging: nil) ⇒ Collection
Returns a new instance of Collection.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/workable/collection.rb', line 8 def initialize(data:, next_page_method:, transform_mapping:, root_key:, paging: nil) @data = data if paging @next_page = paging['next'] @next_page_method = next_page_method @transform_mapping = transform_mapping @root_key = root_key end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/workable/collection.rb', line 6 def data @data end |
Instance Method Details
#fetch_next_page ⇒ Object
23 24 25 26 27 |
# File 'lib/workable/collection.rb', line 23 def fetch_next_page return unless next_page? @next_page_method.call(@next_page, @transform_mapping, @root_key) end |
#next_page? ⇒ Boolean
19 20 21 |
# File 'lib/workable/collection.rb', line 19 def next_page? !! @next_page end |