wells_fargo 0.2.2 → 0.3.0

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.
@@ -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
- begin
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
@@ -1,3 +1,3 @@
1
1
  module WellsFargo
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jack Danger Canty