diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-05-20 18:10:51 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-05-20 18:12:18 +0900 |
commit | 38a945d615a37f568bdaad02cd1cbec6f9ccafb5 (patch) | |
tree | 0ebc9d3cd2b10f1906c7aa15d7b26da02b92c7af /actionpack/lib/action_controller/metal/strong_parameters.rb | |
parent | ea730adb95c8a970924eaf7d492540095518d457 (diff) | |
parent | 46e84d5b104ca5dca88829c9db7941f0e6ce7aaa (diff) | |
download | rails-38a945d615a37f568bdaad02cd1cbec6f9ccafb5.tar.gz rails-38a945d615a37f568bdaad02cd1cbec6f9ccafb5.tar.bz2 rails-38a945d615a37f568bdaad02cd1cbec6f9ccafb5.zip |
Merge pull request #36302 from eugeneius/parameters_transform_keys_enumerator
Return parameters enumerator from transform_keys/!
Diffstat (limited to 'actionpack/lib/action_controller/metal/strong_parameters.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 8bde82ccca..016a633f71 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -679,18 +679,16 @@ module ActionController # Returns a new <tt>ActionController::Parameters</tt> instance with the # results of running +block+ once for every key. The values are unchanged. def transform_keys(&block) - if block - new_instance_with_inherited_permitted_status( - @parameters.transform_keys(&block) - ) - else - @parameters.transform_keys - end + return to_enum(:transform_keys) unless block_given? + new_instance_with_inherited_permitted_status( + @parameters.transform_keys(&block) + ) end # Performs keys transformation and returns the altered # <tt>ActionController::Parameters</tt> instance. def transform_keys!(&block) + return to_enum(:transform_keys!) unless block_given? @parameters.transform_keys!(&block) self end |