class Shoulda::Matchers::ActiveModel::NumericalityMatchers::RangeMatcher
@private
def build_comparison_submatcher(value, operator)
def build_comparison_submatcher(value, operator) ComparisonMatcher.new(@numericality_matcher, value, operator). for(@attribute). with_message(@message). on(@context) end
def build_submatchers
def build_submatchers submatcher_combos.map do |value, operator| build_comparison_submatcher(value, operator) end end
def initialize(numericality_matcher, attribute, range)
def initialize(numericality_matcher, attribute, range) super(attribute) unless numericality_matcher.respond_to? :diff_to_compare raise ArgumentError, 'numericality_matcher is invalid' end @numericality_matcher = numericality_matcher @range = range @attribute = attribute end
def matches?(subject)
def matches?(subject) @subject = subject submatchers.matches?(subject) end
def range_description
def range_description "from #{Shoulda::Matchers::Util.inspect_range(@range)}" end
def simple_description
def simple_description description = '' if expects_strict? description << ' strictly' end description + "disallow :#{attribute} from being a number that is not " + range_description end
def submatcher_combos
def submatcher_combos @range.minmax.zip(OPERATORS) end
def submatchers
def submatchers @_submatchers ||= NumericalityMatchers::Submatchers.new(build_submatchers) end