aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-05-22 10:42:33 -0400
committerGitHub <noreply@github.com>2019-05-22 10:42:33 -0400
commit2a08f79e6f34a80c03ef502ca7d25c75d5b0371c (patch)
tree292c84d471ecd6570e2ba4e04cddb410b6617acb /actionpack/lib/action_controller
parent206cee578a915fe5199bac2a83c99f828bd77132 (diff)
parentbc7e94503a3fb30d6e02898fc2d08285eb0b552b (diff)
downloadrails-2a08f79e6f34a80c03ef502ca7d25c75d5b0371c.tar.gz
rails-2a08f79e6f34a80c03ef502ca7d25c75d5b0371c.tar.bz2
rails-2a08f79e6f34a80c03ef502ca7d25c75d5b0371c.zip
Merge pull request #36294 from gustavogr/add-deep-transform-keys-to-strong-params
Added deep_transform_keys to StrongParameters
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 016a633f71..6a07a73d94 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -693,6 +693,23 @@ module ActionController
self
end
+ # Returns a new <tt>ActionController::Parameters</tt> instance with the
+ # results of running +block+ once for every key. This includes the keys
+ # from the root hash and from all nested hashes and arrays. The values are unchanged.
+ def deep_transform_keys(&block)
+ new_instance_with_inherited_permitted_status(
+ @parameters.deep_transform_keys(&block)
+ )
+ end
+
+ # Returns the <tt>ActionController::Parameters</tt> instance changing its keys.
+ # This includes the keys from the root hash and from all nested hashes and arrays.
+ # The values are unchanged.
+ def deep_transform_keys!(&block)
+ @parameters.deep_transform_keys!(&block)
+ self
+ end
+
# Deletes a key-value pair from +Parameters+ and returns the value. If
# +key+ is not found, returns +nil+ (or, with optional code block, yields
# +key+ and returns the result). Cf. +#extract!+, which returns the