From bbe7b7f504ea5010712ee37d84f8c86682dd14f8 Mon Sep 17 00:00:00 2001 From: Pablo Herrero Date: Thu, 23 Apr 2015 16:33:23 -0300 Subject: Replace use of alias chains with prepend at core_ext/date --- .../lib/active_support/core_ext/date/operators.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/date/operators.rb (limited to 'activesupport/lib/active_support/core_ext/date/operators.rb') diff --git a/activesupport/lib/active_support/core_ext/date/operators.rb b/activesupport/lib/active_support/core_ext/date/operators.rb new file mode 100644 index 0000000000..decf099624 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/date/operators.rb @@ -0,0 +1,16 @@ +require 'active_support/core_ext/date_and_time/with_duration' + +module ActiveSupport + module DateOperators # :nodoc: + include DateAndTime::WithDuration + + # Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there. + def <=>(other) + if other.is_a?(Time) + self.to_datetime <=> other + else + super + end + end + end +end -- cgit v1.2.3