Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#path(path, separator = '.') ⇒ Object

Access nested hashes as a period-separated path


47
48
49
50
51
# File 'lib/gemfury.rb', line 47

def path(path, separator = '.')
  path.split(separator).inject(self) do |hash, part|
    hash.is_a?(Hash) ? hash[part] : nil
  end
end