From 7872cc992bac76e976334d0c20649d69aad5652e Mon Sep 17 00:00:00 2001 From: Diego Carrion Date: Fri, 4 Mar 2011 12:04:22 -0300 Subject: refactored Time#<=> and DateTime#<=> by removing unnecessary calls without losing performance Signed-off-by: Santiago Pastorino --- .../lib/active_support/core_ext/date_time/calculations.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/date_time') 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 -- cgit v1.2.3