Sha256: 38c36c7f3c65d4abcb3e8e3c5e4cf68329ee663c0fded6b4e47675b818a2f473
Contents?: true
Size: 843 Bytes
Versions: 21
Compression:
Stored size: 843 Bytes
Contents
# frozen_string_literal: true module Appydave module Tools module Types # Hash with indifferent access class IndifferentAccessHash < Hash def initialize(initial_hash = {}) super() update(initial_hash) end def [](key) super(convert_key(key)) end def []=(key, value) super(convert_key(key), value) end def fetch(key, *args) super(convert_key(key), *args) end def delete(key) super(convert_key(key)) end private def convert_key(key) key.is_a?(Symbol) ? key.to_s : key end def update(initial_hash) initial_hash.each do |key, value| self[convert_key(key)] = value end end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems