Class: Elasticonf::Loader

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/elasticonf/loader.rb

Instance Method Summary collapse

Instance Method Details

#get(key) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/elasticonf/loader.rb', line 3

def get(key)
  unless [String, Symbol].include?(key.class)
    raise ArgumentError, "String or Symbol expected #{key.class} given"
  end
  
  hash, items = self, key.split('.')
  
  while (item = items.shift)
    (hash = hash[item.to_sym]) || break
  end

  hash
end