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
# File 'lib/haveapi/client/resource_instance_list.rb', line 4

def initialize(client, api, resource, action, response)
  @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.



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

def api_response
  @response
end

#metaObject



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

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.



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

def total_count
  meta[:total_count]
end