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
50
51
52
53
|
# File 'lib/magento/base.rb', line 50
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
33
34
35
|
# File 'lib/magento/base.rb', line 33
def id
@attributes["#{self.class.to_s.split('::').last.underscore.downcase}_id"]
end
|
#id=(_id) ⇒ Object
37
38
39
|
# File 'lib/magento/base.rb', line 37
def id=(_id)
@attributes["#{self.class.to_s.split('::').last.underscore.downcase}_id"] = _id
end
|
#initialize(attributes = {}) ⇒ Object
28
29
30
|
# File 'lib/magento/base.rb', line 28
def initialize(attributes = {})
@attributes = attributes.dup
end
|
#object_attributes=(new_attributes) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/magento/base.rb', line 41
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
|