Class: Shoulda::Lotus::Matchers::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/lotus/matchers.rb

Instance Method Summary collapse

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