Sha256: bd9bdd5f891848e1858eaf39fe5d5e6136c81c7665e2e327c6268bd52d507f88
Contents?: true
Size: 1 KB
Versions: 12
Compression:
Stored size: 1 KB
Contents
# Override Hash class with convenience methods class Hash # Transform each key in Hash to a symbol. Privately used by non-self method # @param [Object] value Value inside hash to transform keys under def self.transform_keys_to_symbols(value) return value unless value.is_a?(Hash) hash = value.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = Hash.transform_keys_to_symbols(v); } hash end # Take keys of hash and transform those to a symbols def transform_keys_to_symbols each_with_object({}) { |(k, v), memo| memo[k.to_sym] = Hash.transform_keys_to_symbols(v); } end # Value present in nested Hash. # @return [Boolean] Whether value is included in nested Hash def include_value?(value) each_value do |v| return true if v == value next unless v.is_a? Hash v.each_value do |v| return true if v == value next unless v.is_a? Hash v.each_value do |v| return true if v == value end end end false end end
Version data entries
12 entries across 12 versions & 1 rubygems