diff options
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/Rakefile | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/decimal.rb | 25 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/helpers/numeric.rb | 13 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/immutable_string.rb | 11 |
4 files changed, 27 insertions, 24 deletions
diff --git a/activemodel/Rakefile b/activemodel/Rakefile index d62c7b46c8..c7f97a4258 100644 --- a/activemodel/Rakefile +++ b/activemodel/Rakefile @@ -18,6 +18,6 @@ namespace :test do task :isolated do Dir.glob("#{dir}/test/**/*_test.rb").all? do |file| sh(Gem.ruby, "-w", "-I#{dir}/lib", "-I#{dir}/test", file) - end or raise "Failures" + end || raise("Failures") end end diff --git a/activemodel/lib/active_model/type/decimal.rb b/activemodel/lib/active_model/type/decimal.rb index 6266933636..6c5c0451c6 100644 --- a/activemodel/lib/active_model/type/decimal.rb +++ b/activemodel/lib/active_model/type/decimal.rb @@ -16,18 +16,19 @@ module ActiveModel private def cast_value(value) - casted_value = case value - when ::Float - convert_float_to_big_decimal(value) - when ::Numeric, ::String - BigDecimal(value, precision.to_i) - else - if value.respond_to?(:to_d) - value.to_d - else - cast_value(value.to_s) - end - end + casted_value = \ + case value + when ::Float + convert_float_to_big_decimal(value) + when ::Numeric, ::String + BigDecimal(value, precision.to_i) + else + if value.respond_to?(:to_d) + value.to_d + else + cast_value(value.to_s) + end + end apply_scale(casted_value) end diff --git a/activemodel/lib/active_model/type/helpers/numeric.rb b/activemodel/lib/active_model/type/helpers/numeric.rb index ec1d1daf1a..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 41e4a2a1ac..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 |