class Nitlink::HashWithIndifferentAccess

Public Class Methods

new(hash = {}) click to toggle source
Calls superclass method
# File lib/nitlink/hash_with_indifferent_access.rb, line 3
def initialize(hash = {})
  super()
  hash.each do |key, value|
    self[convert_key(key)] = value
  end
end

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/nitlink/hash_with_indifferent_access.rb, line 10
def [](key)
  super(convert_key(key))
end
[]=(key, value) click to toggle source
Calls superclass method
# File lib/nitlink/hash_with_indifferent_access.rb, line 14
def []=(key, value)
  super(convert_key(key), value)
end
delete(key) click to toggle source
Calls superclass method
# File lib/nitlink/hash_with_indifferent_access.rb, line 18
def delete(key)
  super(convert_key(key))
end
fetch(key, *args) click to toggle source
Calls superclass method
# File lib/nitlink/hash_with_indifferent_access.rb, line 22
def fetch(key, *args)
  super(convert_key(key), *args)
end
key?(key) click to toggle source
Calls superclass method
# File lib/nitlink/hash_with_indifferent_access.rb, line 26
def key?(key)
  super(convert_key(key))
end
merge(other) click to toggle source
# File lib/nitlink/hash_with_indifferent_access.rb, line 34
def merge(other)
  dup.merge!(other)
end
merge!(other) click to toggle source
# File lib/nitlink/hash_with_indifferent_access.rb, line 38
def merge!(other)
  other.each do |key, value|
    self[convert_key(key)] = value
  end
  self
end
replace(other_hash) click to toggle source
Calls superclass method
# File lib/nitlink/hash_with_indifferent_access.rb, line 53
def replace(other_hash)
  super(other_hash)
end
reverse_merge(other) click to toggle source
# File lib/nitlink/hash_with_indifferent_access.rb, line 45
def reverse_merge(other)
  self.class.new(other).merge(self)
end
reverse_merge!(other_hash) click to toggle source
# File lib/nitlink/hash_with_indifferent_access.rb, line 49
def reverse_merge!(other_hash)
  replace(reverse_merge(other_hash))
end
to_hash() click to toggle source

Convert to a Hash with String keys.

# File lib/nitlink/hash_with_indifferent_access.rb, line 58
def to_hash
  Hash.new(default).merge!(self)
end
values_at(*indices) click to toggle source
# File lib/nitlink/hash_with_indifferent_access.rb, line 30
def values_at(*indices)
  indices.map { |key| self[convert_key(key)] }
end

Protected Instance Methods

convert_key(key) click to toggle source
# File lib/nitlink/hash_with_indifferent_access.rb, line 64
def convert_key(key)
  key.is_a?(Symbol) ? key.to_s : key
end