Class: Hash

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

Overview

Polyfill #dig for Ruby 2.2 and earlier

Instance Method Summary collapse

Instance Method Details

#dig(*parts) ⇒ Object



79
80
81
82
83
# File 'lib/gemfury.rb', line 79

def dig(*parts)
  parts.inject(self) do |hash, part|
    hash.is_a?(Hash) ? hash[part] : nil
  end
end