Class | HashWithIndifferentAccess |
In: |
vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
|
Parent: | Hash |
this class has dubious semantics and we only have it so that people can write params[:key] instead of params[‘key’]
[]= | -> | regular_writer |
# 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
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 21 21: def []=(key, value) 22: regular_writer(convert_key(key), convert_value(value)) 23: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 61 61: def convert_key(key) 62: key.kind_of?(Symbol) ? key.to_s : key 63: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 64 64: def convert_value(value) 65: value.is_a?(Hash) ? value.with_indifferent_access : value 66: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 14 14: def default(key) 15: self[key.to_s] if key.is_a?(Symbol) 16: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 56 56: def delete(key) 57: super(convert_key(key)) 58: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 48 48: def dup 49: HashWithIndifferentAccess.new(self) 50: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 40 40: def fetch(key, *extras) 41: super(convert_key(key), *extras) 42: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 32 32: def key?(key) 33: super(convert_key(key)) 34: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 52 52: def merge(hash) 53: self.dup.update(hash) 54: end
# File vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 25 25: def update(other_hash) 26: other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) } 27: self 28: end