aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/decimal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/type/decimal.rb')
-rw-r--r--activemodel/lib/active_model/type/decimal.rb25
1 files changed, 13 insertions, 12 deletions
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