this class has dubious semantics and we only have it so that people can write params[:key] instead of params[‘key’]
Methods
- []=
- convert_key
- convert_value
- default
- delete
- dup
- fetch
- key?
- merge
- new
- stringify_keys!
- symbolize_keys!
- update
- values_at
Public Class methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 5
5: def initialize(constructor = {})
6: if constructor.is_a?(Hash)
7: super()
8: update(constructor)
9: else
10: super(constructor)
11: end
12: end
Public Instance methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 25
25: def []=(key, value)
26: regular_writer(convert_key(key), convert_value(value))
27: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 68
68: def convert_key(key)
69: key.kind_of?(Symbol) ? key.to_s : key
70: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 71
71: def convert_value(value)
72: value.is_a?(Hash) ? value.with_indifferent_access : value
73: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 14
14: def default(key = nil)
15: if key.is_a?(Symbol) && include?(key = key.to_s)
16: self[key]
17: else
18: super
19: end
20: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 60
60: def delete(key)
61: super(convert_key(key))
62: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 52
52: def dup
53: HashWithIndifferentAccess.new(self)
54: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 44
44: def fetch(key, *extras)
45: super(convert_key(key), *extras)
46: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 36
36: def key?(key)
37: super(convert_key(key))
38: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 56
56: def merge(hash)
57: self.dup.update(hash)
58: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 64
64: def stringify_keys!; self end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 65
65: def symbolize_keys!; self end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 29
29: def update(other_hash)
30: other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
31: self
32: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 48
48: def values_at(*indices)
49: indices.collect {|key| self[convert_key(key)]}
50: end