Class: RBatch::ConfigElement

Inherits:
Hash
  • Object
show all
Defined in:
lib/rbatch/config.rb

Instance Method Summary (collapse)

Constructor Details

- (ConfigElement) initialize(hash)

Returns a new instance of ConfigElement



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rbatch/config.rb', line 62

def initialize(hash)
  if hash
    hash.each_key do |key|
      if hash[key].class == Hash
        self[key] = ConfigElement.new(hash[key])
      else
        self[key] = hash[key]
      end
    end
  end
end

Instance Method Details

- (Object) [](key)



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rbatch/config.rb', line 74

def[](key)
  if self.has_key?(key)
    super
  else
    if key.class == Symbol
      raise RBatch::ConfigException, "Value of key(:#{key} (Symbol)) does not exist. By any chance, dou you mistake key class Symbol for String?"
    elsif key.class == String
      raise RBatch::ConfigException, "Value of key(\"#{key}\" (String)) does not exist"
    else
      raise RBatch::ConfigException, "Value of key(#{key}) does not exist."
    end
    raise
  end
end