Class: SamcartAPI::SamcartObject
- Inherits:
-
Object
- Object
- SamcartAPI::SamcartObject
show all
- Defined in:
- lib/samcart_api/samcart_object.rb
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ SamcartObject
Returns a new instance of SamcartObject.
5
6
7
|
# File 'lib/samcart_api/samcart_object.rb', line 5
def initialize(attributes = {})
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/samcart_api/samcart_object.rb', line 13
def method_missing(method_name, *args)
if @attributes.key?(method_name.to_s)
warn '[DEPRECATION] Dot notation (.) is deprecated and ' \
"will be removed in the next major version. Use hash access ['#{method_name}'] instead."
@attributes[method_name.to_s]
else
super
end
end
|
Instance Method Details
#[](key) ⇒ Object
9
10
11
|
# File 'lib/samcart_api/samcart_object.rb', line 9
def [](key)
@attributes[key]
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
24
25
26
|
# File 'lib/samcart_api/samcart_object.rb', line 24
def respond_to_missing?(method_name, include_private = false)
@attributes.key?(method_name.to_s) || super
end
|
#to_h ⇒ Object
28
29
30
|
# File 'lib/samcart_api/samcart_object.rb', line 28
def to_h
@attributes
end
|