clinth3o-acdc 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/acdc/body.rb +9 -8
  2. data/lib/acdc.rb +1 -1
  3. 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('@elements',@elements ||= {})
78
- child.instance_variable_set('@attributes',@attributes ||= {})
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
- @elements.update(name => opts.merge(:type => type))
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
- @attributes ||= {}
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
@@ -9,7 +9,7 @@ require File.join(File.dirname(__FILE__),"acdc","body")
9
9
 
10
10
  module AcDc
11
11
 
12
- VERSION = [0,1,3] unless defined?(AcDc::VERSION)
12
+ VERSION = [0,1,4] unless defined?(AcDc::VERSION)
13
13
 
14
14
  if defined?(JAIL_BREAK)
15
15
  Element.class_eval{ alias :to_s :acdc }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clinth3o-acdc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clint Hill