Method: ActiveSupport::HashWithIndifferentAccess#dig

Defined in:
activesupport/lib/active_support/hash_with_indifferent_access.rb

#dig(*args) ⇒ Object

Same as Hash#dig where the key passed as argument can be either a string or a symbol:

counters = ActiveSupport::HashWithIndifferentAccess.new
counters[:foo] = { bar: 1 }

counters.dig('foo', 'bar')     # => 1
counters.dig(:foo, :bar)       # => 1
counters.dig(:zoo)             # => nil


208
209
210
211
# File 'activesupport/lib/active_support/hash_with_indifferent_access.rb', line 208

def dig(*args)
  args[0] = convert_key(args[0]) if args.size > 0
  super(*args)
end