diff options
author | Diego Carrion <dc.rec1@gmail.com> | 2011-03-04 12:04:22 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-03-04 16:50:24 -0200 |
commit | 7872cc992bac76e976334d0c20649d69aad5652e (patch) | |
tree | be186d827453f22708daa059e6bf812de9400e9c /activesupport/lib/active_support/core_ext/date_time/calculations.rb | |
parent | 0db915efd1240f493c50b7b9f5d1ea5f1e3eec10 (diff) | |
download | rails-7872cc992bac76e976334d0c20649d69aad5652e.tar.gz rails-7872cc992bac76e976334d0c20649d69aad5652e.tar.bz2 rails-7872cc992bac76e976334d0c20649d69aad5652e.zip |
refactored Time#<=> and DateTime#<=> by removing unnecessary calls without losing performance
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time/calculations.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_time/calculations.rb | 10 |
1 files changed, 2 insertions, 8 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 8d01376f1d..8d924ad420 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -1,6 +1,4 @@ require 'rational' unless RUBY_VERSION >= '1.9.2' -require 'active_support/core_ext/object/acts_like' -require 'active_support/core_ext/time/zones' class DateTime class << self @@ -105,11 +103,7 @@ class DateTime end # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime - def compare_with_coercion(other) - other = other.comparable_time if other.respond_to?(:comparable_time) - other = other.to_datetime unless other.acts_like?(:date) - compare_without_coercion(other) + def <=>(other) + super other.to_datetime end - alias_method :compare_without_coercion, :<=> - alias_method :<=>, :compare_with_coercion end |