Class: FractalApi::PagedResponse
- Inherits:
-
Object
- Object
- FractalApi::PagedResponse
- Defined in:
- lib/fractal_api/paged_response.rb
Instance Attribute Summary collapse
-
#links ⇒ Object
Returns the value of attribute links.
-
#result_class ⇒ Object
Returns the value of attribute result_class.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(json:, result_class:) ⇒ PagedResponse
constructor
A new instance of PagedResponse.
- #next_page_url ⇒ Object
Constructor Details
#initialize(json:, result_class:) ⇒ PagedResponse
Returns a new instance of PagedResponse.
7 8 9 10 11 12 13 14 |
# File 'lib/fractal_api/paged_response.rb', line 7 def initialize(json:, result_class:) @result_class = result_class @links = json[:links] || {} @results = json.fetch(:results, []).map do |result| result_class.build(json: result) end end |
Instance Attribute Details
#links ⇒ Object
Returns the value of attribute links.
5 6 7 |
# File 'lib/fractal_api/paged_response.rb', line 5 def links @links end |
#result_class ⇒ Object
Returns the value of attribute result_class.
5 6 7 |
# File 'lib/fractal_api/paged_response.rb', line 5 def result_class @result_class end |
#results ⇒ Object
Returns the value of attribute results.
5 6 7 |
# File 'lib/fractal_api/paged_response.rb', line 5 def results @results end |
Instance Method Details
#next_page_url ⇒ Object
16 17 18 19 20 |
# File 'lib/fractal_api/paged_response.rb', line 16 def next_page_url return unless links[:next] links[:next] end |