This implementation is HODEL-HASH-9600 compliant
Methods
Public Class methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 3
3: def initialize(constructor = {})
4: if constructor.is_a?(Hash)
5: super()
6: update(constructor.stringify_keys)
7: else
8: super(constructor)
9: end
10: end
Public Instance methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 14
14: def [](key)
15: case key
16: when Symbol: regular_reader(key.to_s) || regular_reader(key)
17: when String: regular_reader(key) || regular_reader(key.to_sym)
18: else regular_reader(key)
19: end
20: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 24
24: def []=(key, value)
25: regular_writer(convert_key(key), convert_value(value))
26: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 48
48: def convert_key(key)
49: key.kind_of?(Symbol) ? key.to_s : key
50: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 51
51: def convert_value(value)
52: value.is_a?(Hash) ? value.with_indifferent_access : value
53: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 39
39: def fetch(key, *extras)
40: super(convert_key(key), *extras)
41: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 31
31: def key?(key)
32: super(convert_key(key))
33: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 27
27: def update(hash)
28: hash.each {|key, value| self[key] = value}
29: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 43
43: def values_at(*indices)
44: indices.collect {|key| self[convert_key(key)]}
45: end