class Phaxio::Resource::Collection
Attributes
collection[RW]
The raw response data
page[RW]
The raw response data
per_page[RW]
The raw response data
raw_data[RW]
The raw response data
total[RW]
The raw response data
Public Class Methods
new(response_data, resource)
click to toggle source
Returns a new collection of resource instances for this data. Generally this is not called directly.
@see Phaxio::Resource.response_collection
# File lib/phaxio/resource.rb, line 141 def initialize response_data, resource if response_data.key? 'paging' self.total = response_data['paging']['total'] self.per_page = response_data['paging']['per_page'] self.page = response_data['paging']['page'] end self.raw_data = response_data['data'] self.collection = raw_data.map { |record_data| resource.response_record record_data } end
Public Instance Methods
[](idx)
click to toggle source
# File lib/phaxio/resource.rb, line 151 def [] idx collection[idx] end
each(&block)
click to toggle source
# File lib/phaxio/resource.rb, line 155 def each(&block) collection.each(&block) end
length()
click to toggle source
# File lib/phaxio/resource.rb, line 159 def length collection.length end
size()
click to toggle source
# File lib/phaxio/resource.rb, line 163 def size length end