class Shoulda::Matchers::ActiveModel::AllowValueMatcher::AttributeSettersAndValidators

@private

Attributes

tuples[R]

Public Class Methods

new(allow_value_matcher, values) click to toggle source
# File lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb, line 9
def initialize(allow_value_matcher, values)
  @tuples = values.map do |attribute_name, value|
    AttributeSetterAndValidator.new(
      allow_value_matcher,
      attribute_name,
      value,
    )
  end
end

Public Instance Methods

each(&block) click to toggle source
# File lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb, line 19
def each(&block)
  tuples.each(&block)
end
first_failing() click to toggle source
# File lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb, line 27
def first_failing
  tuples.detect(&method(:does_not_match?))
end
first_passing() click to toggle source
# File lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb, line 23
def first_passing
  tuples.detect(&method(:matches?))
end

Private Instance Methods

does_not_match?(tuple) click to toggle source
# File lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb, line 41
def does_not_match?(tuple)
  !matches?(tuple)
end
matches?(tuple) click to toggle source
# File lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb, line 37
def matches?(tuple)
  tuple.attribute_setter.set! && tuple.validator.call
end