Class: EAAL::Result::ResultContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/eaal/result.rb

Overview

Result Container class, …

Direct Known Subclasses

EAAL::Rowset::RowBase

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResultContainer

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

#attribsObject

Returns the value of attribute attribs.



17
18
19
# File 'lib/eaal/result.rb', line 17

def attribs
  @attribs
end

#containerObject

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_hashObject



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