lib/zoom/core_ext/hash/keys.rb
def deep_transform_keys_in_object(object, &block)
      case object
      when Array
        object.map { |e| deep_transform_keys_in_object(e, &block) }
      when Hash
        object.each_with_object({}) do |(key, value), result|
          result[yield(key)] = deep_transform_keys_in_object(value, &block)
        end
        # Hash[object.map { |key, value| [yield(key), deep_transform_keys_in_object(value, &block)] }]
      else
        object
      end
    end
# support methods for deep transforming nested hashes and arrays
support methods for deep transforming nested hashes and arrays
support methods for deep transforming nested hashes and arrays
def deep_transform_keys_in_object(object, &block)
      case object
      when Array
        object.map { |e| deep_transform_keys_in_object(e, &block) }
      when Hash
        object.each_with_object({}) do |(key, value), result|
          result[yield(key)] = deep_transform_keys_in_object(value, &block)
        end
      else
        object
      end
    end
def deep_transform_keys_in_object ( object , & block ) case object when Array object . map { | e | deep_transform_keys_in_object ( e , & block ) } when Hash object . each_with_object ( { } ) do | ( key , value ) , result | result [ yield ( key ) ] = deep_transform_keys_in_object ( value , & block ) end else object end end
support methods for deep transforming nested hashes and arrays
support methods for deep transforming nested hashes and arrays
# Hash[object.map { |key, value| [yield(key), deep_transform_keys_in_object(value, &block)] }]
object
block