Module: Magento::Base::InstanceMethods
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
46
47
48
49
|
# File 'lib/magento/base.rb', line 46
def method_missing(method, *args)
return nil unless @attributes
@attributes[method.to_s]
end
|
Instance Method Details
#id ⇒ Object
TODO: find out if the id naming is consistent
29
30
31
|
# File 'lib/magento/base.rb', line 29
def id
@attributes["#{self.class.to_s.split('::').last.underscore.downcase}_id"]
end
|
#id=(_id) ⇒ Object
33
34
35
|
# File 'lib/magento/base.rb', line 33
def id=(_id)
@attributes["#{self.class.to_s.split('::').last.underscore.downcase}_id"] = _id
end
|
#initialize(attributes = {}) ⇒ Object
24
25
26
|
# File 'lib/magento/base.rb', line 24
def initialize(attributes = {})
@attributes = attributes.dup
end
|
#object_attributes=(new_attributes) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/magento/base.rb', line 37
def object_attributes=(new_attributes)
return if new_attributes.nil?
attributes = new_attributes.dup
attributes.stringify_keys!
attributes.each do |k, v|
send(k + "=", v)
end
end
|