提交 3ece0d89 编写于 作者: O ojab

Use Range#cover? for Date inclusion validator

上级 01b8a23a
......@@ -30,14 +30,15 @@ def delimiter
@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?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册