activemodel/lib/active_model/validations/clusivity.rb
# In Ruby 1.9 <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.
In Ruby 1.9 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.
In Ruby 1 . 9 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 .
def inclusion_method(enumerable)
        if enumerable.is_a? Range
          case enumerable.first
          when Numeric, Time, DateTime
            :cover?
          else
            :include?
          end
        else
          :include?
        end
      end
def inclusion_method ( enumerable ) if enumerable . is_a? Range case enumerable . first when Numeric , Time , DateTime :cover? else :include? end else :include? end end
In Ruby 1.9 <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.
In Ruby 1 . 9 <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 .
enumerable
<not_specific>