Class: HaveAPI::Client::ResourceInstanceList

Inherits:
Array
  • Object
show all
Defined in:
lib/haveapi/client/resource_instance_list.rb

Overview

A list of ResourceInstance objects.

Instance Method Summary collapse

Constructor Details

#initialize(client, api, resource, action, response) ⇒ ResourceInstanceList

Returns a new instance of ResourceInstanceList.



4
5
6
7
8
9
10
11
# File 'lib/haveapi/client/resource_instance_list.rb', line 4

def initialize(client, api, resource, action, response)
  super()
  @response = response

  response.response.each do |hash|
    self << ResourceInstance.new(client, api, resource, action: action, response: hash)
  end
end

Instance Method Details

#api_responseObject

Return the API response that created this object.



14
15
16
# File 'lib/haveapi/client/resource_instance_list.rb', line 14

def api_response
  @response
end

#metaObject



18
19
20
# File 'lib/haveapi/client/resource_instance_list.rb', line 18

def meta
  @response.meta
end

#total_countObject

Return the total count of items. Note that for this method to work, the action that returns this object list must be invoked with meta: {count: true}, otherwise the object count is not sent.



26
27
28
# File 'lib/haveapi/client/resource_instance_list.rb', line 26

def total_count
  meta[:total_count]
end