Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update documentation and change the range method name to delimiter.

  • Loading branch information...
commit a63f7a136401b59db52fb802180f6c9793d83bc2 1 parent 770fa81
@rafaelfranca rafaelfranca authored
View
10 activemodel/lib/active_model/validations/clusivity.rb
@@ -4,10 +4,10 @@ module ActiveModel
module Validations
module Clusivity #:nodoc:
ERROR_MESSAGE = "An object with the method #include? or a proc or lambda is required, " <<
- "and must be supplied as the :in option of the configuration hash"
+ "and must be supplied as the :in (or :within) option of the configuration hash"
def check_validity!
- unless [:include?, :call].any?{ |method| range.respond_to?(method) }
+ unless [:include?, :call].any?{ |method| delimiter.respond_to?(method) }
raise ArgumentError, ERROR_MESSAGE
end
end
@@ -15,12 +15,12 @@ def check_validity!
private
def include?(record, value)
- exclusions = range.respond_to?(:call) ? range.call(record) : range
+ exclusions = delimiter.respond_to?(:call) ? delimiter.call(record) : delimiter
exclusions.send(inclusion_method(exclusions), value)
end
- def range
- @range ||= options[:in] || options[:within]
+ def delimiter
+ @delimiter ||= options[:in] || options[:within]
end
# In Ruby 1.9 <tt>Range#include?</tt> on non-numeric ranges checks all possible values in the
View
1  activemodel/lib/active_model/validations/exclusion.rb
@@ -30,6 +30,7 @@ module HelperMethods
# * <tt>:in</tt> - An enumerable object of items that the value shouldn't
# be part of. This can be supplied as a proc or lambda which returns an
# enumerable. If the enumerable is a range the test is performed with
+ # * <tt>:within</tt> - A synonym(or alias) for <tt>:in</tt>
# <tt>Range#cover?</tt>, otherwise with <tt>include?</tt>.
# * <tt>:message</tt> - Specifies a custom error message (default is: "is
# reserved").
View
1  activemodel/lib/active_model/validations/inclusion.rb
@@ -30,6 +30,7 @@ module HelperMethods
# supplied as a proc or lambda which returns an enumerable. If the
# enumerable is a range the test is performed with <tt>Range#cover?</tt>,
# otherwise with <tt>include?</tt>.
+ # * <tt>:within</tt> - A synonym(or alias) for <tt>:in</tt>
# * <tt>:message</tt> - Specifies a custom error message (default is: "is
# not included in the list").
# * <tt>:allow_nil</tt> - If set to +true+, skips this validation if the
Please sign in to comment.
Something went wrong with that request. Please try again.