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:
parent
810dff7c9f
commit
db63406cb0
2 changed files with 13 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue