This class has dubious semantics and we only have it so that people can write params[:key] instead of params[‘key’] and they get the same value for both keys.

Methods
Public Class methods
new(constructor = {})
    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 6
 6:   def initialize(constructor = {})
 7:     if constructor.is_a?(Hash)
 8:       super()
 9:       update(constructor)
10:     else
11:       super(constructor)
12:     end
13:   end
Public Instance methods
[]=(key, value)

Assigns a new value to the hash:

  hash = HashWithIndifferentAccess.new
  hash[:key] = "value"
    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 31
31:   def []=(key, value)
32:     regular_writer(convert_key(key), convert_value(value))
33:   end
convert_key(key)
     # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 115
115:     def convert_key(key)
116:       key.kind_of?(Symbol) ? key.to_s : key
117:     end
convert_value(value)
     # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 119
119:     def convert_value(value)
120:       case value
121:       when Hash
122:         value.with_indifferent_access
123:       when Array
124:         value.collect { |e| e.is_a?(Hash) ? e.with_indifferent_access : e }
125:       else
126:         value
127:       end
128:     end
default(key = nil)
    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 15
15:   def default(key = nil)
16:     if key.is_a?(Symbol) && include?(key = key.to_s)
17:       self[key]
18:     else
19:       super
20:     end
21:   end
delete(key)

Removes a specified key from the hash.

     # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 101
101:   def delete(key)
102:     super(convert_key(key))
103:   end
dup()

Returns an exact copy of the hash.

    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 84
84:   def dup
85:     HashWithIndifferentAccess.new(self)
86:   end
fetch(key, *extras)

Fetches the value for the specified key, same as doing hash[key]

    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 68
68:   def fetch(key, *extras)
69:     super(convert_key(key), *extras)
70:   end
key?(key)

Checks the hash for a key matching the argument passed in:

  hash = HashWithIndifferentAccess.new
  hash["key"] = "value"
  hash.key? :key  # => true
  hash.key? "key" # => true
    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 59
59:   def key?(key)
60:     super(convert_key(key))
61:   end
merge(hash)

Merges the instantized and the specified hashes together, giving precedence to the values from the second hash Does not overwrite the existing hash.

    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 90
90:   def merge(hash)
91:     self.dup.update(hash)
92:   end
reverse_merge(other_hash)

Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second. This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess.

    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 96
96:   def reverse_merge(other_hash)
97:     super other_hash.with_indifferent_access
98:   end
stringify_keys!()
     # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 105
105:   def stringify_keys!; self end
symbolize_keys!()
     # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 106
106:   def symbolize_keys!; self end
to_hash()

Convert to a Hash with String keys.

     # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 110
110:   def to_hash
111:     Hash.new(default).merge(self)
112:   end
to_options!()
     # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 107
107:   def to_options!; self end
update(other_hash)

Updates the instantized hash with values from the second:

  hash_1 = HashWithIndifferentAccess.new
  hash_1[:key] = "value"

  hash_2 = HashWithIndifferentAccess.new
  hash_2[:key] = "New Value!"

  hash_1.update(hash_2) # => {"key"=>"New Value!"}
    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 45
45:   def update(other_hash)
46:     other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
47:     self
48:   end
values_at(*indices)

Returns an array of the values at the specified indices:

  hash = HashWithIndifferentAccess.new
  hash[:a] = "x"
  hash[:b] = "y"
  hash.values_at("a", "b") # => ["x", "y"]
    # File activesupport/lib/active_support/core_ext/hash/indifferent_access.rb, line 79
79:   def values_at(*indices)
80:     indices.collect {|key| self[convert_key(key)]}
81:   end