Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#try_path(*args) ⇒ Object

Try provided path on hash

Parameters:

args

Keys of hash you want to try

Returns:

Value or nil if key does not exist


11
12
13
14
15
# File 'lib/utils/hash.rb', line 11

def try_path(*args)
  value = self
  args.each { |arg_name| value = value.nil? ? nil : value[arg_name] }
  value
end