mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
5e2622ecfc
Also remove some dead code from repositories datatables
18 lines
No EOL
551 B
Ruby
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 |