module Metanorma::Utils::Hash
def deep_merge(second)
def deep_merge(second) merger = proc { |_, v1, v2| if ::Hash === v1 && ::Hash === v2 v1.merge(v2, &merger) elsif ::Array === v1 && ::Array === v2 v1 | v2 elsif [:undefined].include?(v2) v1 else v2 end } merge(second.to_h, &merger) end
def stringify_all_keys
def stringify_all_keys result = {} each do |k, v| result[k.to_s] = case v when ::Hash, ::Array v.stringify_all_keys else v end end result end
def symbolize_all_keys
def symbolize_all_keys result = {} each do |k, v| result[k.to_sym] = case v when ::Hash, ::Array v.symbolize_all_keys else v end end result end