Class: Ruberto::Collection
- Inherits:
-
Object
- Object
- Ruberto::Collection
- Defined in:
- lib/ruberto/collection.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#next_href ⇒ Object
readonly
Returns the value of attribute next_href.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data:, next_href:) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(data:, next_href:) ⇒ Collection
Returns a new instance of Collection.
14 15 16 17 |
# File 'lib/ruberto/collection.rb', line 14 def initialize(data:, next_href:) @data = data @next_href = next_href end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/ruberto/collection.rb', line 5 def data @data end |
#next_href ⇒ Object (readonly)
Returns the value of attribute next_href.
5 6 7 |
# File 'lib/ruberto/collection.rb', line 5 def next_href @next_href end |
Class Method Details
.from_response(response_body, type:) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/ruberto/collection.rb', line 7 def self.from_response(response_body, type:) new( data: response_body[:data]&.map { |attrs| type.new(attrs) }, next_href: response_body[:next_href] ) end |