Class: Drip::Resource
- Inherits:
-
Object
- Object
- Drip::Resource
- Defined in:
- lib/drip/resource.rb
Direct Known Subclasses
Account, Broadcast, Campaign, CampaignSubscription, Error, Order, Purchase, Subscriber, Tag, Webhook, Workflow, WorkflowTrigger
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#raw_attributes ⇒ Object
readonly
Returns the value of attribute raw_attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(raw_data = {}) ⇒ Resource
constructor
A new instance of Resource.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to?(method_name, include_private = false) ⇒ Boolean
- #singular? ⇒ Boolean
Constructor Details
#initialize(raw_data = {}) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 |
# File 'lib/drip/resource.rb', line 9 def initialize(raw_data = {}) @raw_attributes = raw_data.dup.freeze @attributes = process(@raw_attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
26 27 28 |
# File 'lib/drip/resource.rb', line 26 def method_missing(method_name, *args, &block) attributes.keys.include?(method_name.to_s) ? attributes[method_name.to_s] : super end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/drip/resource.rb', line 7 def attributes @attributes end |
#raw_attributes ⇒ Object (readonly)
Returns the value of attribute raw_attributes.
7 8 9 |
# File 'lib/drip/resource.rb', line 7 def raw_attributes @raw_attributes end |
Class Method Details
.resource_name ⇒ Object
14 15 16 |
# File 'lib/drip/resource.rb', line 14 def self.resource_name "resource" end |
Instance Method Details
#respond_to?(method_name, include_private = false) ⇒ Boolean
22 23 24 |
# File 'lib/drip/resource.rb', line 22 def respond_to?(method_name, include_private = false) attributes.keys.include?(method_name.to_s) || super end |
#singular? ⇒ Boolean
18 19 20 |
# File 'lib/drip/resource.rb', line 18 def singular? true end |