Class: EasyAutomation::DataElements

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_automation/data_elements.rb

Instance Method Summary collapse

Constructor Details

#initialize(elements) ⇒ DataElements

Builds magic functions to handle elements



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/easy_automation/data_elements.rb', line 14

def initialize(elements)
  @elements = {}
  @elements.merge!(elements || {})
  @elements.each do |key, value|
    if (value.class.to_s == "Array" || value.class.to_s == "Hash")
      eval (%{
        def #{key}
          return @elements[:#{key}]

        end
      })
    elsif value.class.to_s == 'Fixnum'
      eval(%{
        def #{key}
          return #{value}
        end
      })
    else
      eval(%{
        def #{key}
          return #{value.dump}
        end
      })
    end
  end
end