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,7 +3,8 @@ module ActiveModel
|
||||||
module Helpers
|
module Helpers
|
||||||
module Numeric # :nodoc:
|
module Numeric # :nodoc:
|
||||||
def cast(value)
|
def cast(value)
|
||||||
value = case value
|
value = \
|
||||||
|
case value
|
||||||
when true then 1
|
when true then 1
|
||||||
when false then 0
|
when false then 0
|
||||||
when ::String then value.presence
|
when ::String then value.presence
|
||||||
|
|
|
@ -17,7 +17,8 @@ module ActiveModel
|
||||||
private
|
private
|
||||||
|
|
||||||
def cast_value(value)
|
def cast_value(value)
|
||||||
result = case value
|
result = \
|
||||||
|
case value
|
||||||
when true then "t"
|
when true then "t"
|
||||||
when false then "f"
|
when false then "f"
|
||||||
else value.to_s
|
else value.to_s
|
||||||
|
|
Loading…
Reference in a new issue