Class: Magento::Abstract
- Inherits:
-
Object
show all
- Defined in:
- lib/abstract.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Abstract
Returns a new instance of Abstract.
5
6
7
8
|
# File 'lib/abstract.rb', line 5
def initialize(attributes = {})
@connection = Magento::Connection.new
@attributes = attributes.dup
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
37
38
39
40
|
# File 'lib/abstract.rb', line 37
def method_missing(method, *args)
return nil unless @attributes
@attributes[method.to_s]
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3
4
5
|
# File 'lib/abstract.rb', line 3
def attributes
@attributes
end
|
Class Method Details
.commit(method, *args) ⇒ Object
32
33
34
35
|
# File 'lib/abstract.rb', line 32
def self.commit(method, *args)
connect
@connection.call(method, args)
end
|
.connect ⇒ Object
10
11
12
|
# File 'lib/abstract.rb', line 10
def self.connect
@connection ||= Magento::Connection.new
end
|
.first ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/abstract.rb', line 14
def self.first
return nil unless respond_to?(:list)
n = 0
while list(n)[0] == nil
n+=1
end
return list(n)[0]
end
|
Instance Method Details
#object_attributes=(new_attributes) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/abstract.rb', line 23
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
|