diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-09 14:12:05 -0800 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2014-12-22 20:17:26 -0800 |
commit | 047b2a9fcf893287a01de621dc40d6b29e701747 (patch) | |
tree | 5b99f50ccd382b132de8edbd9e187be254ab57b4 /activesupport/lib/active_support | |
parent | 8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7 (diff) | |
download | rails-047b2a9fcf893287a01de621dc40d6b29e701747.tar.gz rails-047b2a9fcf893287a01de621dc40d6b29e701747.tar.bz2 rails-047b2a9fcf893287a01de621dc40d6b29e701747.zip |
Check `respond_to` before delegation due to: https://github.com/ruby/ruby/commit/d781caaf313b8649948c107bba277e5ad7307314
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_time/calculations.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index 0481bd2195..0ff36eeb6d 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -138,6 +138,12 @@ class DateTime # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime def <=>(other) - super other.kind_of?(Infinity) ? other : other.to_datetime + if other.kind_of?(Infinity) + super + elsif other.respond_to? :to_datetime + super other.to_datetime + else + nil + end end end |