class AWS::Core::IndifferentHash

A utility class to provide indifferent access to hash data.

Inspired by ActiveSupport’s HashWithIndifferentAccess, this class has a few notable differences:

These features were omitted because our primary use for this class is to wrap a 1-level hash as a return value, but we want the user to access the values with string or symbol keys.

@private

Public Class Methods

new(*args) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 33
def initialize *args
  if args.first.is_a?(Hash)
    super()
    merge!(*args)
  else
    super(*args)
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 50
def [] key
  _getter(_convert_key(key))
end
Also aliased as: _getter
[]=(key, value) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 45
def []=(key, value)
  _setter(_convert_key(key), value)
end
Also aliased as: _setter, store
_getter(key) click to toggle source
Alias for: []
_setter(key, value) click to toggle source
Alias for: []=
delete(key) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 77
def delete key
  super(_convert_key(key))
end
fetch(key, *extras, &block) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 73
def fetch key, *extras, &block
  super(_convert_key(key), *extras, &block)
end
has_key?(key) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 66
def has_key? key
  super(_convert_key(key))
end
Also aliased as: key?, member?, include?
include?(key) click to toggle source
Alias for: has_key?
key?(key) click to toggle source
Alias for: has_key?
member?(key) click to toggle source
Alias for: has_key?
merge(hash) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 62
def merge hash
  self.dup.merge!(hash)
end
merge!(hash) click to toggle source
# File lib/aws/core/indifferent_hash.rb, line 54
def merge! hash
  hash.each_pair do |key,value|
    self[key] = value 
  end
  self
end
Also aliased as: update
store(key, value) click to toggle source
Alias for: []=
update(hash) click to toggle source
Alias for: merge!