mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Duration#coerce should always return a Scalar
This speeds up Range.new(x, y).step(Duration).each { ... } Fixes #34888
This commit is contained in:
parent
80c7038bbc
commit
36de9eadaa
1 changed files with 4 additions and 1 deletions
|
@ -214,8 +214,11 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
def coerce(other) #:nodoc:
|
||||
if Scalar === other
|
||||
case other
|
||||
when Scalar
|
||||
[other, self]
|
||||
when Duration
|
||||
[Scalar.new(other.value), self]
|
||||
else
|
||||
[Scalar.new(other), self]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue