Class: ActionDispatch::Request::Utils::ParamEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/request/utils.rb

Overview

:nodoc:

Direct Known Subclasses

NoNilParamEncoder

Class Method Summary collapse

Class Method Details

.handle_array(params) ⇒ Object



71
72
73
# File 'lib/action_dispatch/request/utils.rb', line 71

def self.handle_array(params)
  params.map! { |el| normalize_encode_params(el) }
end

.normalize_encode_params(params) ⇒ Object

Convert nested Hash to HashWithIndifferentAccess.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/action_dispatch/request/utils.rb', line 52

def self.normalize_encode_params(params)
  case params
  when Array
    handle_array params
  when Hash
    if params.has_key?(:tempfile)
      ActionDispatch::Http::UploadedFile.new(params)
    else
      hwia = ActiveSupport::HashWithIndifferentAccess.new
      params.each_pair do |key, val|
        hwia[key] = normalize_encode_params(val)
      end
      hwia
    end
  else
    params
  end
end