aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorojab <ojab@ojab.ru>2016-03-24 10:16:47 +0000
committerojab <ojab@ojab.ru>2016-03-24 11:36:07 +0000
commit3ece0d89d4e453dce2c65d6be59c30d75e6c827a (patch)
treeab6b2d308555de24faa7f9f4c7f82ce1c9d53975 /activemodel
parent01b8a23a7c1fd3c4419e7441b0ce611187f869c8 (diff)
downloadrails-3ece0d89d4e453dce2c65d6be59c30d75e6c827a.tar.gz
rails-3ece0d89d4e453dce2c65d6be59c30d75e6c827a.tar.bz2
rails-3ece0d89d4e453dce2c65d6be59c30d75e6c827a.zip
Use Range#cover? for Date inclusion validator
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/validations/clusivity.rb7
1 files changed, 4 insertions, 3 deletions
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 <tt>Range#include?</tt> on non-number-or-time-ish ranges checks all
+ # In Ruby 2.2 <tt>Range#include?</tt> on non-number-or-time-ish ranges checks all
# possible values in the range for equality, which is slower but more accurate.
# <tt>Range#cover?</tt> 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?