Class: Shoulda::Lotus::Matchers::Matcher
- Inherits:
-
Object
- Object
- Shoulda::Lotus::Matchers::Matcher
- Defined in:
- lib/shoulda/lotus/matchers.rb
Instance Method Summary collapse
-
#initialize(target, attribute, validation) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches? ⇒ Boolean
Constructor Details
#initialize(target, attribute, validation) ⇒ Matcher
11 12 13 14 15 |
# File 'lib/shoulda/lotus/matchers.rb', line 11 def initialize(target, attribute, validation) @target = target @attribute = attribute @validation = validation end |
Instance Method Details
#matches? ⇒ Boolean
17 18 19 20 |
# File 'lib/shoulda/lotus/matchers.rb', line 17 def matches? @target.valid? @target.errors.for(@attribute).select { |error| error.attribute == @attribute.to_s && error.validation == @validation }.size > 0 end |