Class: AbstractApiWrapper::Response::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/abstract_api_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*options) ⇒ Collection

Returns a new instance of Collection.



147
148
149
150
# File 'lib/abstract_api_wrapper.rb', line 147

def initialize(*options)
  @request = options[1] if options[1]
  super(options[0])
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



145
146
147
# File 'lib/abstract_api_wrapper.rb', line 145

def request
  @request
end

Instance Method Details

#headersObject



152
153
154
# File 'lib/abstract_api_wrapper.rb', line 152

def headers
  @headers ||= @request.headers
end

#paginationObject



156
157
158
159
160
161
162
163
164
165
166
# File 'lib/abstract_api_wrapper.rb', line 156

def pagination
  @pagination ||= Hashie::Mash.new(
    next_page: headers['x-next-page'].to_i,
    offset: headers['x-offset'].to_i,
    page: headers['x-page'].to_i,
    per_page: headers['x-per-page'].to_i,
    prev_page: headers['prev_page'].to_i,
    total: headers['x-total'].to_i,
    total_pages: headers['x-total-pages'].to_i
  )
end