clinth3o-acdc 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/acdc/body.rb +9 -8
- data/lib/acdc.rb +1 -1
- metadata +1 -1
data/lib/acdc/body.rb
CHANGED
@@ -74,8 +74,8 @@ module AcDc
|
|
74
74
|
|
75
75
|
class << self
|
76
76
|
def inherited(child)
|
77
|
-
child.instance_variable_set('@
|
78
|
-
child.instance_variable_set('@
|
77
|
+
child.instance_variable_set('@declared_elements', @declared_elements)
|
78
|
+
child.instance_variable_set('@declared_attributes', @declared_attributes)
|
79
79
|
end
|
80
80
|
|
81
81
|
# Declare an Element for this Body
|
@@ -83,27 +83,27 @@ module AcDc
|
|
83
83
|
#@param [Class] type A type to use for the element (enforcement)
|
84
84
|
#@option options [Boolean] :single False if object is a collection
|
85
85
|
def element(*options)
|
86
|
-
@elements ||= {}
|
87
86
|
name = options.first
|
88
87
|
type = options.second || nil
|
89
88
|
opts = options.extract_options!
|
90
|
-
|
89
|
+
declared_elements.update(name => opts.merge(:type => type))
|
91
90
|
end
|
92
91
|
|
93
92
|
# Declare an attribute for this Body
|
94
93
|
def attribute(name, value = nil)
|
95
|
-
|
96
|
-
@attributes.update(name => value)
|
94
|
+
declared_attributes.update(name => value)
|
97
95
|
end
|
98
96
|
|
99
97
|
# Returns the Hash list of Elements declared
|
100
98
|
def declared_elements
|
101
|
-
@elements
|
99
|
+
@elements ||= {}
|
100
|
+
@declared_elements ||= @elements[to_s] ||= {}
|
102
101
|
end
|
103
102
|
|
104
103
|
# Returns a Hash list of Attributes declared
|
105
104
|
def declared_attributes
|
106
|
-
@attributes
|
105
|
+
@attributes ||= {}
|
106
|
+
@declared_attributes ||= @attributes[to_s] ||= {}
|
107
107
|
end
|
108
108
|
|
109
109
|
# Converts the XML to a Class object found in the library
|
@@ -140,6 +140,7 @@ module AcDc
|
|
140
140
|
end
|
141
141
|
|
142
142
|
private
|
143
|
+
|
143
144
|
def options_for(key)
|
144
145
|
self.class.declared_elements[key]
|
145
146
|
end
|
data/lib/acdc.rb
CHANGED