Sha256: f68ba2515eb15980c29a9b546c19a2e45a8fe0bac17e1594f3d4ad0a6a348339
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module Shoulda module Matchers module ActiveModel module NumericalityMatchers # @private class Submatchers def initialize(submatchers) @submatchers = submatchers end def matches?(subject) @subject = subject failing_submatchers.empty? end def does_not_match?(subject) @subject = subject non_failing_submatchers.empty? end def failure_message failing_submatcher.failure_message end def failure_message_when_negated non_failing_submatcher.failure_message_when_negated end def add(submatcher) @submatchers << submatcher end private def failing_submatchers @_failing_submatchers ||= @submatchers.reject do |submatcher| submatcher.matches?(@subject) end end def non_failing_submatchers @_non_failing_submatchers ||= @submatchers.reject do |submatcher| submatcher.does_not_match?(@subject) end end def failing_submatcher failing_submatchers.last end def non_failing_submatcher non_failing_submatchers.last end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shoulda-matchers-6.0.0 | lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb |