Class: EAAL::Result::ResultContainer
- Inherits:
-
Object
- Object
- EAAL::Result::ResultContainer
- Defined in:
- lib/eaal/result.rb
Overview
Result Container class, …
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attribs ⇒ Object
Returns the value of attribute attribs.
-
#container ⇒ Object
Returns the value of attribute container.
Instance Method Summary collapse
- #add_element(key, val) ⇒ Object
-
#initialize ⇒ ResultContainer
constructor
A new instance of ResultContainer.
- #method_missing(method, *args) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ ResultContainer
Returns a new instance of ResultContainer.
19 20 21 22 |
# File 'lib/eaal/result.rb', line 19 def initialize self.container = {} self.attribs = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/eaal/result.rb', line 28 def method_missing(method, *args) if self.attribs.has_key?(method.id2name) self.attribs[method.id2name] else self.container[method.id2name] end end |
Instance Attribute Details
#attribs ⇒ Object
Returns the value of attribute attribs.
17 18 19 |
# File 'lib/eaal/result.rb', line 17 def attribs @attribs end |
#container ⇒ Object
Returns the value of attribute container.
17 18 19 |
# File 'lib/eaal/result.rb', line 17 def container @container end |
Instance Method Details
#add_element(key, val) ⇒ Object
24 25 26 |
# File 'lib/eaal/result.rb', line 24 def add_element(key, val) self.container.merge!({key => val}) end |
#to_hash ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/eaal/result.rb', line 36 def to_hash if self.container == {} vars = self.instance_variables vars.delete_at(0) # delete container var name vars.each {|v| self.container[v.to_s.gsub("@","")] = self.instance_variable_get v } end return self.container.dup end |