Class: Klaviyo::Resource::KlaviyoCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/klaviyo/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data) ⇒ KlaviyoCollection

Returns a new instance of KlaviyoCollection.



24
25
26
27
28
# File 'lib/klaviyo/resource.rb', line 24

def initialize(raw_data)
  data = raw_data.is_a?(String) ? MultiJson.load(raw_data) : raw_data
  @items = data.delete('data').map { |attrs| Klaviyo::Resource.build(attrs) }
  @meta = data
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



22
23
24
# File 'lib/klaviyo/resource.rb', line 22

def items
  @items
end

#metaObject (readonly)

Returns the value of attribute meta.



22
23
24
# File 'lib/klaviyo/resource.rb', line 22

def meta
  @meta
end

Instance Method Details

#each(&blk) ⇒ Object



30
31
32
# File 'lib/klaviyo/resource.rb', line 30

def each(&blk)
  item.each(&blk)
end