wells_fargo 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wells_fargo/element.rb +13 -6
- data/lib/wells_fargo/version.rb +1 -1
- metadata +3 -3
data/lib/wells_fargo/element.rb
CHANGED
@@ -13,12 +13,7 @@ module WellsFargo
|
|
13
13
|
def add_child name, attributes = {}, &block
|
14
14
|
|
15
15
|
child_class_name = NameMap[name.to_s]
|
16
|
-
|
17
|
-
child_class = Element.const_get(child_class_name)
|
18
|
-
rescue
|
19
|
-
Element.const_set(child_class_name, Class.new(Element))
|
20
|
-
child_class = Element.const_get(child_class_name)
|
21
|
-
end
|
16
|
+
child_class = ensure_element_class child_class_name
|
22
17
|
|
23
18
|
child = child_class.new(xml, attributes)
|
24
19
|
capture = proc do |x|
|
@@ -43,6 +38,18 @@ module WellsFargo
|
|
43
38
|
|
44
39
|
protected
|
45
40
|
|
41
|
+
def ensure_element_class class_name
|
42
|
+
begin
|
43
|
+
klass = Element.const_get(class_name)
|
44
|
+
top_class = eval("::#{class_name}") rescue false
|
45
|
+
raise 'pass to rescue clause' if top_class
|
46
|
+
rescue
|
47
|
+
Element.const_set(class_name, Class.new(Element))
|
48
|
+
klass = Element.const_get(class_name)
|
49
|
+
end
|
50
|
+
klass
|
51
|
+
end
|
52
|
+
|
46
53
|
def method_missing method, *args, &block
|
47
54
|
if self.class.children.any? {|c| method.to_sym == c[:name] }
|
48
55
|
add_child method, *args, &block
|
data/lib/wells_fargo/version.rb
CHANGED