module ActiveModel::Validations::Clusivity

def check_validity!

def check_validity!
  unless delimiter.respond_to?(:include?) || delimiter.respond_to?(:call) || delimiter.respond_to?(:to_sym)
    raise ArgumentError, ERROR_MESSAGE
  end
end

def delimiter

def delimiter
  @delimiter ||= options[:in] || options[:within]
end

def include?(record, value)

def include?(record, value)
  members = if delimiter.respond_to?(:call)
    delimiter.call(record)
  elsif delimiter.respond_to?(:to_sym)
    record.send(delimiter)
  else
    delimiter
  end
  if value.is_a?(Array)
    value.all? { |v| members.public_send(inclusion_method(members), v) }
  else
    members.public_send(inclusion_method(members), value)
  end
end

def inclusion_method(enumerable)

or DateTime ranges.
endpoints, which is fast but is only accurate on Numeric, Time, Date,
Range#cover? uses the previous logic of comparing a value with the range
possible values in the range for equality, which is slower but more accurate.
After Ruby 2.2, Range#include? on non-number-or-time-ish ranges checks all
def inclusion_method(enumerable)
  if enumerable.is_a? Range
    case enumerable.first
    when Numeric, Time, DateTime, Date
      :cover?
    else
      :include?
    end
  else
    :include?
  end
end