Class: Hanami::Router::Params Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/router/params.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Params utilities

Since:

  • 2.0.0

Class Method Summary collapse

Class Method Details

.deep_symbolize(params) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deep symbolize Hash params

Parameters:

  • params (Hash)

    the params to symbolize

Returns:

  • (Hash)

    the symbolized params

Since:

  • 2.0.0



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hanami/router/params.rb', line 18

def self.deep_symbolize(params)
  params.each_with_object({}) do |(key, value), output|
    output[key.to_sym] =
      case value
      when ::Hash
        deep_symbolize(value)
      when Array
        value.map do |item|
          item.is_a?(::Hash) ? deep_symbolize(item) : item
        end
      else
        value
      end
  end
end