From 3ece0d89d4e453dce2c65d6be59c30d75e6c827a Mon Sep 17 00:00:00 2001 From: ojab Date: Thu, 24 Mar 2016 10:16:47 +0000 Subject: Use Range#cover? for Date inclusion validator --- activemodel/lib/active_model/validations/clusivity.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/validations/clusivity.rb b/activemodel/lib/active_model/validations/clusivity.rb index bad9e4f9a9..d49af603bb 100644 --- a/activemodel/lib/active_model/validations/clusivity.rb +++ b/activemodel/lib/active_model/validations/clusivity.rb @@ -30,14 +30,15 @@ module ActiveModel @delimiter ||= options[:in] || options[:within] end - # In Ruby 1.9 Range#include? on non-number-or-time-ish ranges checks all + # In Ruby 2.2 Range#include? on non-number-or-time-ish ranges checks all # possible values in the range for equality, which is slower but more accurate. # Range#cover? uses the previous logic of comparing a value with the range - # endpoints, which is fast but is only accurate on Numeric, Time, or DateTime ranges. + # endpoints, which is fast but is only accurate on Numeric, Time, Date, + # or DateTime ranges. def inclusion_method(enumerable) if enumerable.is_a? Range case enumerable.first - when Numeric, Time, DateTime + when Numeric, Time, DateTime, Date :cover? else :include? -- cgit v1.2.3