Class: Drip::Resource
- Inherits:
-
Object
show all
- Defined in:
- lib/drip/resource.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(raw_data = {}) ⇒ Resource
Returns a new instance of Resource.
5
6
7
8
|
# File 'lib/drip/resource.rb', line 5
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)
attribute_keys.include?(method_name) ? attributes[method_name] : super
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3
4
5
|
# File 'lib/drip/resource.rb', line 3
def attributes
@attributes
end
|
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
3
4
5
|
# File 'lib/drip/resource.rb', line 3
def raw_attributes
@raw_attributes
end
|
Class Method Details
.resource_name ⇒ Object
10
11
12
|
# File 'lib/drip/resource.rb', line 10
def self.resource_name
"resource"
end
|
Instance Method Details
#attribute_keys ⇒ Object
14
15
16
|
# File 'lib/drip/resource.rb', line 14
def attribute_keys
[]
end
|
#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)
attribute_keys.include?(method_name) || super
end
|
#singular? ⇒ Boolean
18
19
20
|
# File 'lib/drip/resource.rb', line 18
def singular?
true
end
|