Deep Hash transformation using Lambdas

Today I had the need in my job of implementing a similar behaviour of what Rails hash method .deep_symbolize_keys does. Here is a possible implementation of a deep recursive hash transformation, using recursive lambdas.

deep_symbolize_keys = lambda do |hash|  
  return hash unless hash.is_a?(Hash)

  Hash[ hash.map do |key, value|
    # if value is array, loop each element and recursively symbolize keys
    if value.is_a? Array
      value = value.map { |element| symbolize_keys.call(element) }
    # if value is hash, recursively symbolize keys
    elsif value.is_a? Hash
      value = symbolize_keys.call(value)
    end

    [key.to_sym, value]
  end ]
end

deep_symbolize_keys.call(params)