scinote-web/app/utilities/hash_util.rb
Luka Murn 5e2622ecfc Change default repository state to Ruby representation
Also remove some dead code from repositories datatables
2018-04-20 12:31:22 +02:00

18 lines
No EOL
551 B
Ruby

module HashUtil
def deep_stringify_values(obj, include_arrays = true)
if obj.is_a?(Hash)
obj.map { |k, v| [k, deep_stringify_values(v, include_arrays)] }.to_h
elsif include_arrays && obj.is_a?(Array)
obj.map { |i| deep_stringify_values(i, include_arrays) }
else
obj.to_s
end
end
module_function :deep_stringify_values
def deep_stringify_keys_and_values(obj, include_arrays = true)
deep_stringify_values(obj, include_arrays).deep_stringify_keys
end
module_function :deep_stringify_keys_and_values
end