Methods
- #
- C
- D
- E
- F
- H
- I
- K
- M
- N
- R
- S
- T
- U
- V
- W
Class Public methods
new(constructor = {})
Link
new_from_hash_copying_default(hash)
Link
Instance Public methods
[]=(key, value)
Link
Assigns a new value to the hash:
hash = HashWithIndifferentAccess.new hash[:key] = "value"
Also aliased as: regular_writer, store
default(key = nil)
Link
delete(key)
Link
Removes a specified key from the hash.
dup()
Link
Returns an exact copy of the hash.
extractable_options?()
Link
Always returns true, so that Array#extract_options!
finds
members of this class.
has_key?(key)
Link
include?(key)
Link
key?(key)
Link
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
member?(key)
Link
merge(hash)
Link
Merges the instantized and the specified hashes together, giving precedence to the values from the second hash. Does not overwrite the existing hash.
merge!(other_hash)
Link
nested_under_indifferent_access()
Link
regular_update(other_hash)
Link
regular_writer(key, value)
Link
reverse_merge(other_hash)
Link
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
.
reverse_merge!(other_hash)
Link
store(key, value)
Link
stringify_keys()
Link
stringify_keys!()
Link
symbolize_keys()
Link
to_hash()
Link
to_options!()
Link
update(other_hash)
Link
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!"}
Also aliased as: regular_update, merge!
# File activesupport/lib/active_support/hash_with_indifferent_access.rb, line 70 def update(other_hash) if other_hash.is_a? HashWithIndifferentAccess super(other_hash) else other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) } self end end
values_at(*indices)
Link
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"]
with_indifferent_access()
Link
Instance Protected methods
convert_key(key)
Link
convert_value(value)
Link