| Class | HashWithIndifferentAccess |
| In: |
vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
|
| Parent: | Hash |
This implementation is HODEL-HASH-9600 compliant
| []= | -> | regular_writer |
# 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)
7: else
8: super(constructor)
9: end
10: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 18
18: def []=(key, value)
19: regular_writer(convert_key(key), convert_value(value))
20: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 42
42: def convert_key(key)
43: key.kind_of?(Symbol) ? key.to_s : key
44: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 45
45: def convert_value(value)
46: value.is_a?(Hash) ? value.with_indifferent_access : value
47: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 12
12: def default(key)
13: self[key.to_s] if key.is_a?(Symbol)
14: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 33
33: def fetch(key, *extras)
34: super(convert_key(key), *extras)
35: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 25
25: def key?(key)
26: super(convert_key(key))
27: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 21
21: def update(hash)
22: hash.each {|key, value| self[key] = value}
23: end