diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-03-24 12:42:10 -0300 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-03-24 12:42:10 -0300 |
commit | 0741cf9cbc88105dbb2017ae42ddfa2e0793adfc (patch) | |
tree | 28663f9e7c256f84d9389e74e11e449c31dafc60 /activemodel/lib | |
parent | a7d587f284b1360aec9c93695571520b6bdaac45 (diff) | |
parent | 3ece0d89d4e453dce2c65d6be59c30d75e6c827a (diff) | |
download | rails-0741cf9cbc88105dbb2017ae42ddfa2e0793adfc.tar.gz rails-0741cf9cbc88105dbb2017ae42ddfa2e0793adfc.tar.bz2 rails-0741cf9cbc88105dbb2017ae42ddfa2e0793adfc.zip |
Merge pull request #24297 from ojab/master
Use Range#cover? for Date inclusion validator
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/validations/clusivity.rb | 7 |
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? |