Class: Shoulda::Matchers::ActiveModel::AllowValueMatcher::AttributeSettersAndValidators

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb

Instance Method Summary collapse

Constructor Details

#initialize(allow_value_matcher, values) ⇒ AttributeSettersAndValidators

Returns a new instance of AttributeSettersAndValidators.



9
10
11
12
13
14
15
16
17
# 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

Instance Method Details

#each(&block) ⇒ Object



19
20
21
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb', line 19

def each(&block)
  tuples.each(&block)
end

#first_failingObject



27
28
29
# 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_passingObject



23
24
25
# File 'lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb', line 23

def first_passing
  tuples.detect(&method(:matches?))
end