diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2018-03-11 10:00:26 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2018-03-11 10:00:26 +0900 |
commit | 58eda3cfd8b670718ba9b99bdbe137c4320ec32f (patch) | |
tree | 597d72dc509aac5d9c8b6cd61ebe564174f5301f /actionpack/lib | |
parent | 9af6601a46ec6afeafc61597eb10bdc7f175370d (diff) | |
download | rails-58eda3cfd8b670718ba9b99bdbe137c4320ec32f.tar.gz rails-58eda3cfd8b670718ba9b99bdbe137c4320ec32f.tar.bz2 rails-58eda3cfd8b670718ba9b99bdbe137c4320ec32f.zip |
Remove unnecessary `Hash.method_defined?(:dig)` checking
Since Rails 6 requires Ruby 2.4.1+.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 615c90c496..75ca282804 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -580,19 +580,17 @@ module ActionController ) end - if Hash.method_defined?(:dig) - # Extracts the nested parameter from the given +keys+ by calling +dig+ - # at each step. Returns +nil+ if any intermediate step is +nil+. - # - # params = ActionController::Parameters.new(foo: { bar: { baz: 1 } }) - # params.dig(:foo, :bar, :baz) # => 1 - # params.dig(:foo, :zot, :xyz) # => nil - # - # params2 = ActionController::Parameters.new(foo: [10, 11, 12]) - # params2.dig(:foo, 1) # => 11 - def dig(*keys) - convert_value_to_parameters(@parameters.dig(*keys)) - end + # Extracts the nested parameter from the given +keys+ by calling +dig+ + # at each step. Returns +nil+ if any intermediate step is +nil+. + # + # params = ActionController::Parameters.new(foo: { bar: { baz: 1 } }) + # params.dig(:foo, :bar, :baz) # => 1 + # params.dig(:foo, :zot, :xyz) # => nil + # + # params2 = ActionController::Parameters.new(foo: [10, 11, 12]) + # params2.dig(:foo, 1) # => 11 + def dig(*keys) + convert_value_to_parameters(@parameters.dig(*keys)) end # Returns a new <tt>ActionController::Parameters</tt> instance that |