Module: ActionReporter::Utils
- Defined in:
- lib/action_reporter/utils.rb
Class Method Summary collapse
Class Method Details
.deep_transform_values(hash, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/action_reporter/utils.rb', line 5 def deep_transform_values(hash, &block) hash.each_with_object({}) do |(k, v), result| value = if v.is_a?(Hash) deep_transform_values(v, &block) elsif v.is_a?(Array) v.map { |e| e.is_a?(Hash) ? deep_transform_values(e, &block) : e } else v end result[k] = block.call(value) end end |