Class: ActionDispatch::ParamBuilder

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/http/param_builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param_depth_limit) ⇒ ParamBuilder

Returns a new instance of ParamBuilder.



15
16
17
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 15

def initialize(param_depth_limit)
  @param_depth_limit = param_depth_limit
end

Instance Attribute Details

#param_depth_limitObject (readonly)

Returns the value of attribute param_depth_limit.



13
14
15
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 13

def param_depth_limit
  @param_depth_limit
end

Class Method Details

.ignore_leading_bracketsObject



25
26
27
28
29
30
31
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 25

def ignore_leading_brackets
  ActionDispatch.deprecator.warn <<~MSG
    ActionDispatch::ParamBuilder.ignore_leading_brackets is deprecated and have no effect and will be removed in Rails 8.2.
  MSG

  @ignore_leading_brackets
end

.ignore_leading_brackets=(value) ⇒ Object



33
34
35
36
37
38
39
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 33

def ignore_leading_brackets=(value)
  ActionDispatch.deprecator.warn <<~MSG
    ActionDispatch::ParamBuilder.ignore_leading_brackets is deprecated and have no effect and will be removed in Rails 8.2.
  MSG

  @ignore_leading_brackets = value
end

.make_default(param_depth_limit) ⇒ Object

– This implementation is based on Rack::QueryParser, Copyright © 2007-2021 Leah Neukirchen <leahneukirchen.org/infopage.html>



9
10
11
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 9

def self.make_default(param_depth_limit)
  new param_depth_limit
end

Instance Method Details

#from_hash(hash, encoding_template: nil) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 62

def from_hash(hash, encoding_template: nil)
  # Force encodings from encoding template
  hash = Request::Utils::CustomParamEncoder.encode_for_template(hash, encoding_template)

  # Assert valid encoding
  Request::Utils.check_param_encoding(hash)

  # Convert hashes to HWIA (or UploadedFile), and deep-munge nils
  # out of arrays
  hash = Request::Utils.normalize_encode_params(hash)

  hash
end

#from_pairs(pairs, encoding_template: nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 46

def from_pairs(pairs, encoding_template: nil)
  params = make_params

  pairs.each do |k, v|
    if Hash === v
      v = ActionDispatch::Http::UploadedFile.new(v)
    end

    store_nested_param(params, k, v, 0, encoding_template)
  end

  params
rescue ArgumentError => e
  raise InvalidParameterError, e.message, e.backtrace
end

#from_query_string(qs, separator: nil, encoding_template: nil) ⇒ Object



42
43
44
# File 'actionpack/lib/action_dispatch/http/param_builder.rb', line 42

def from_query_string(qs, separator: nil, encoding_template: nil)
  from_pairs QueryParser.each_pair(qs, separator), encoding_template: encoding_template
end