Class: Klaviyo::Resource::KlaviyoCollection
- Inherits:
-
Object
- Object
- Klaviyo::Resource::KlaviyoCollection
- Includes:
- Enumerable
- Defined in:
- lib/klaviyo/resource.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #each(&blk) ⇒ Object
-
#initialize(raw_data) ⇒ KlaviyoCollection
constructor
A new instance of KlaviyoCollection.
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) } = data end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
22 23 24 |
# File 'lib/klaviyo/resource.rb', line 22 def items @items end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
22 23 24 |
# File 'lib/klaviyo/resource.rb', line 22 def end |
Instance Method Details
#each(&blk) ⇒ Object
30 31 32 |
# File 'lib/klaviyo/resource.rb', line 30 def each(&blk) item.each(&blk) end |