From 38f28dca3aa16efd6cc3af6453f2e6b9e9655ec1 Mon Sep 17 00:00:00 2001 From: bUg Date: Tue, 14 Aug 2012 20:28:26 +0200 Subject: Added ability to compare date/time with infinity Date, DateTime, Time and TimeWithZone can now be compared to infinity, so it's now possible to create ranges with one infinite bound and date/time object as another bound. Ex.: @range = Range.new(Date.today, Float::INFINITY) Also it's possible to check inclusion of date/time in range with conversion. Ex.: @range.include?(Time.now + 1.year) # => true @range.include?(DateTime.now + 1.year) # => true Ability to create date/time ranges with infinite bound is required for handling postgresql range types. --- .../active_support/core_ext/numeric/infinite_comparable.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb (limited to 'activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb') diff --git a/activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb b/activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb new file mode 100644 index 0000000000..07d4d7446a --- /dev/null +++ b/activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb @@ -0,0 +1,11 @@ +require 'active_support/core_ext/big_decimal/conversions' +require 'active_support/number_helper' +require 'active_support/core_ext/infinite_comparable' + +class Float + include InfiniteComparable +end + +class BigDecimal + include InfiniteComparable +end -- cgit v1.2.3