1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

apply case-in-assignment pattern

This commit is contained in:
Xavier Noria 2016-09-02 01:34:43 +02:00
parent 810dff7c9f
commit db63406cb0
2 changed files with 13 additions and 11 deletions

View file

@ -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

View file

@ -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