class AWS::Core::IndifferentHash
@api private
the values with string or symbol keys.
wrap a 1-level hash as a return value, but we want the user to access
These features were omitted because our primary use for this class is to
* It will not perserve default value behaviours
* It does not deep merge/convert hashes indifferently, good for fla
* ALL keys are converted to strings (via #to_s)
has a few notable differences:
Inspired by ActiveSupport’s HashWithIndifferentAccess, this class
A utility class to provide indifferent access to hash data.
def [] key
def [] key _getter(_convert_key(key)) end
def []=(key, value)
def []=(key, value) _setter(_convert_key(key), value) end
def _convert_key key
def _convert_key key key.is_a?(String) ? key : key.to_s end
def delete key
def delete key super(_convert_key(key)) end
def fetch key, *extras, &block
def fetch key, *extras, &block super(_convert_key(key), *extras, &block) end
def has_key? key
def has_key? key super(_convert_key(key)) end
def initialize *args
def initialize *args if args.first.is_a?(Hash) super() merge!(*args) else super(*args) end end
def merge hash
def merge hash self.dup.merge!(hash) end
def merge! hash
def merge! hash hash.each_pair do |key,value| self[key] = value end self end