Merge pull request #34899 from rails/speed-up-step

Duration#coerce should always return a Scalar
This commit is contained in:
Aaron Patterson 2019-01-09 09:28:00 -08:00 committed by GitHub
commit 28bb21bf5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -214,8 +214,11 @@ module ActiveSupport
end end
def coerce(other) #:nodoc: def coerce(other) #:nodoc:
if Scalar === other case other
when Scalar
[other, self] [other, self]
when Duration
[Scalar.new(other.value), self]
else else
[Scalar.new(other), self] [Scalar.new(other), self]
end end