Class: Ruberto::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/ruberto/collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/ruberto/collection.rb', line 5

def data
  @data
end

#next_hrefObject (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