Module: Hash::IndifferentAccess

Defined in:
lib/wolf_core/utils/hash_extension.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



9
10
11
# File 'lib/wolf_core/utils/hash_extension.rb', line 9

def [](key)
  fetch(key.to_s) { fetch(key.to_sym) { nil } }
end

#fetch(key, *extras) ⇒ Object



13
14
15
16
17
# File 'lib/wolf_core/utils/hash_extension.rb', line 13

def fetch(key, *extras)
  super(key.to_s, *extras)
rescue KeyError
  super(key.to_sym, *extras)
end

#has_key?(key) ⇒ Boolean Also known as: include?, key?, member?

Returns:

  • (Boolean)


19
20
21
# File 'lib/wolf_core/utils/hash_extension.rb', line 19

def has_key?(key)
  key?(key.to_s) || key?(key.to_sym)
end