diff options
author | Xavier Noria <fxn@hashref.com> | 2016-09-02 01:34:43 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-09-02 01:34:43 +0200 |
commit | db63406cb007ab3756d2a96d2e0b5d4e777f8231 (patch) | |
tree | 1dfe5f008bb30f2396290a520d190e723bc4b218 /activemodel | |
parent | 810dff7c9fa9b2a38eb1560ce0378d760529ee6b (diff) | |
download | rails-db63406cb007ab3756d2a96d2e0b5d4e777f8231.tar.gz rails-db63406cb007ab3756d2a96d2e0b5d4e777f8231.tar.bz2 rails-db63406cb007ab3756d2a96d2e0b5d4e777f8231.zip |
apply case-in-assignment pattern
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/type/helpers/numeric.rb | 13 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/immutable_string.rb | 11 |
2 files changed, 13 insertions, 11 deletions
diff --git a/activemodel/lib/active_model/type/helpers/numeric.rb b/activemodel/lib/active_model/type/helpers/numeric.rb index eee745cbc4..98533f8771 100644 --- a/activemodel/lib/active_model/type/helpers/numeric.rb +++ b/activemodel/lib/active_model/type/helpers/numeric.rb @@ -3,12 +3,13 @@ module ActiveModel module Helpers module Numeric # :nodoc: def cast(value) - value = case value - when true then 1 - when false then 0 - when ::String then value.presence - else value - end + value = \ + case value + when true then 1 + when false then 0 + when ::String then value.presence + else value + end super(value) end diff --git a/activemodel/lib/active_model/type/immutable_string.rb b/activemodel/lib/active_model/type/immutable_string.rb index 75654e1334..58268540e5 100644 --- a/activemodel/lib/active_model/type/immutable_string.rb +++ b/activemodel/lib/active_model/type/immutable_string.rb @@ -17,11 +17,12 @@ module ActiveModel private def cast_value(value) - result = case value - when true then "t" - when false then "f" - else value.to_s - end + result = \ + case value + when true then "t" + when false then "f" + else value.to_s + end result.freeze end end |