class Shoulda::Matchers::ActiveModel::NumericalityMatchers::RangeMatcher
@private
Constants
- OPERATORS
Public Class Methods
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 13 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
Calls superclass method
Public Instance Methods
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 24 def matches?(subject) @subject = subject submatchers.matches?(subject) end
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 41 def range_description "from #{Shoulda::Matchers::Util.inspect_range(@range)}" end
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 29 def simple_description description = '' if expects_strict? description << ' strictly' end description + "disallow :#{attribute} from being a number that is not " + range_description end
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 45 def submatchers @_submatchers ||= NumericalityMatchers::Submatchers.new(build_submatchers) end
Private Instance Methods
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 61 def build_comparison_submatcher(value, operator) ComparisonMatcher.new(@numericality_matcher, value, operator). for(@attribute). with_message(@message). on(@context) end
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 51 def build_submatchers submatcher_combos.map do |value, operator| build_comparison_submatcher(value, operator) end end
Source
# File lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb, line 57 def submatcher_combos @range.minmax.zip(OPERATORS) end