aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@github.com>2019-01-09 09:28:00 -0800
committerGitHub <noreply@github.com>2019-01-09 09:28:00 -0800
commit28bb21bf5aaf5ed8b7b1ca8fc51aad6ca89f1f73 (patch)
tree4979dd623f7a1e59f96c3bea0a13b7aa9f47095f /activesupport
parentea65d92f1924648e72f93bb0e8e5fc62a56d0bac (diff)
parent36de9eadaa9193cbc43a501aa345636d77d3b5c1 (diff)
downloadrails-28bb21bf5aaf5ed8b7b1ca8fc51aad6ca89f1f73.tar.gz
rails-28bb21bf5aaf5ed8b7b1ca8fc51aad6ca89f1f73.tar.bz2
rails-28bb21bf5aaf5ed8b7b1ca8fc51aad6ca89f1f73.zip
Merge pull request #34899 from rails/speed-up-step
Duration#coerce should always return a Scalar
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/duration.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index 314c926ac0..97b4634d7b 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -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