Class: SantanderChile::ApiClient::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/santander_chile/api_client/collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:) ⇒ Collection

Returns a new instance of Collection.



7
8
9
# File 'lib/santander_chile/api_client/collection.rb', line 7

def initialize(data:)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

Class Method Details

.from_response(response, dig_keys:, type:) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/santander_chile/api_client/collection.rb', line 11

def self.from_response(response, dig_keys:, type:)
  body = response.body
  new(
    data: body.dig(*dig_keys).map {
      |attrs|
      type.new(attrs)
    },
  )
end

Instance Method Details

#each(*args, &block) ⇒ Object



21
22
23
# File 'lib/santander_chile/api_client/collection.rb', line 21

def each(*args, &block)
  @data.each(*args, &block)
end