class GraphQL::Client::HashWithIndifferentAccess
Also see ActiveSupport::HashWithIndifferentAccess.
strings, symbols, snake or camel case.
Public: Implements a read only hash where keys can be accessed by
def [](key)
def [](key) @hash[convert_value(key)] end
def convert_value(key)
def convert_value(key) case key when String, Symbol key = key.to_s @aliases.fetch(key, key) else key end end
def each_key(&block)
def each_key(&block) @hash.each_key { |key| yield convert_value(key) } end
def fetch(key, *args, &block)
def fetch(key, *args, &block) @hash.fetch(convert_value(key), *args, &block) end
def initialize(hash = {})
def initialize(hash = {}) @hash = hash @aliases = {} hash.each_key do |key| if key.is_a?(String) key_alias = ActiveSupport::Inflector.underscore(key) @aliases[key_alias] = key if key != key_alias end end freeze end
def key?(key)
def key?(key) @hash.key?(convert_value(key)) end