Class: Klaviyo::Resource::KlaviyoObject
- Inherits:
-
Struct
- Object
- Struct
- Klaviyo::Resource::KlaviyoObject
- Defined in:
- lib/klaviyo/resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/klaviyo/resource.rb', line 4 def method_missing(method_name, *arguments, &block) if attrs.key?(method_name.to_s) || attrs.key?("$#{method_name}") attr_value = attrs[method_name.to_s] || attrs["$#{method_name}"] if attr_value.is_a?(Hash) && attr_value.key?('object') && attr_value.key?('id') attrs[method_name.to_s] = Klaviyo::Resource.build(attr_value) else attr_value end else super end end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs
3 4 5 |
# File 'lib/klaviyo/resource.rb', line 3 def attrs @attrs end |