Class: ColumnApi::Collection

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, has_more:) ⇒ Collection

Returns a new instance of Collection.



20
21
22
23
# File 'lib/column_api/collection.rb', line 20

def initialize(data:, has_more:)
  @data = data
  @has_more = has_more
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



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

def has_more
  @has_more
end

Class Method Details

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



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/column_api/collection.rb', line 7

def self.from_response(response, key:, type:)
  new(
    data: response[key].map do |attrs|
      if type.respond_to?(:from_response)
        type.from_response(attrs)
      else
        type.new(attrs)
      end
    end,
    has_more: response["has_more"]
  )
end