diff options
author | Xavier Noria <fxn@hashref.com> | 2016-11-13 11:23:45 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-11-13 11:46:05 +0100 |
commit | 58201f7d2e9d4ba7e36c89fe6988c4b3e1a635d6 (patch) | |
tree | 4db964a770396792d0873e8611fac20367e0ad0d /actionpack/lib | |
parent | ee7556cb08382f311bd40eec0e377aaa878c42e8 (diff) | |
download | rails-58201f7d2e9d4ba7e36c89fe6988c4b3e1a635d6.tar.gz rails-58201f7d2e9d4ba7e36c89fe6988c4b3e1a635d6.tar.bz2 rails-58201f7d2e9d4ba7e36c89fe6988c4b3e1a635d6.zip |
revises style in recent code (of mine)
This alternative case expressions read better for my taste, and look more uniform
in a file where other similar case expressions are used (without dynamic clauses).
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 1977632c4e..b398d24b59 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -807,11 +807,12 @@ module ActionController def permit_any_in_parameters(params) self.class.new.tap do |sanitized| params.each do |key, value| - if permitted_scalar?(value) + case value + when ->(v) { permitted_scalar?(v) } sanitized[key] = value - elsif value.is_a?(Array) + when Array sanitized[key] = permit_any_in_array(value) - elsif value.is_a?(Parameters) + when Parameters sanitized[key] = permit_any_in_parameters(value) else # Filter this one out. @@ -824,9 +825,10 @@ module ActionController def permit_any_in_array(array) [].tap do |sanitized| array.each do |element| - if permitted_scalar?(element) + case element + when ->(e) { permitted_scalar?(e) } sanitized << element - elsif element.is_a?(Parameters) + when Parameters sanitized << permit_any_in_parameters(element) else # Filter this one out. |