diff options
author | Gustavo Gutierrez <gustavogut1993@gmail.com> | 2019-05-17 15:13:03 +0200 |
---|---|---|
committer | Gustavo Gutierrez <gustavogut1993@gmail.com> | 2019-05-22 16:04:31 +0200 |
commit | bc7e94503a3fb30d6e02898fc2d08285eb0b552b (patch) | |
tree | 292c84d471ecd6570e2ba4e04cddb410b6617acb /actionpack/lib/action_controller/metal/strong_parameters.rb | |
parent | 206cee578a915fe5199bac2a83c99f828bd77132 (diff) | |
download | rails-bc7e94503a3fb30d6e02898fc2d08285eb0b552b.tar.gz rails-bc7e94503a3fb30d6e02898fc2d08285eb0b552b.tar.bz2 rails-bc7e94503a3fb30d6e02898fc2d08285eb0b552b.zip |
Implemented deep_transform_keys/! for ActionController::Parameters
Diffstat (limited to 'actionpack/lib/action_controller/metal/strong_parameters.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 17 |
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 |