Class: Remarkable::Mongoid::Matchers::ValidateAssociationMatcher
- Inherits:
-
Object
- Object
- Remarkable::Mongoid::Matchers::ValidateAssociationMatcher
- Defined in:
- lib/remarkable/mongoid/validate_association.rb
Instance Attribute Summary collapse
-
#attr ⇒ Object
Returns the value of attribute attr.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
-
#initialize(attr) ⇒ ValidateAssociationMatcher
constructor
A new instance of ValidateAssociationMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attr) ⇒ ValidateAssociationMatcher
Returns a new instance of ValidateAssociationMatcher.
19 20 21 |
# File 'lib/remarkable/mongoid/validate_association.rb', line 19 def initialize(attr) self.attr = attr.to_sym end |
Instance Attribute Details
#attr ⇒ Object
Returns the value of attribute attr.
17 18 19 |
# File 'lib/remarkable/mongoid/validate_association.rb', line 17 def attr @attr end |
Instance Method Details
#description ⇒ Object
29 30 31 |
# File 'lib/remarkable/mongoid/validate_association.rb', line 29 def description "validates the :#{attr} association" end |
#failure_message_for_should ⇒ Object
33 34 35 |
# File 'lib/remarkable/mongoid/validate_association.rb', line 33 def "\nAssociation validation failure\nExpected: #{@subject.class} to validate the '#{attr}' association" end |
#matches?(subject) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/remarkable/mongoid/validate_association.rb', line 23 def matches?(subject) @subject = subject validations = @subject._validators[attr] validations.detect { |k| k.class == ::Mongoid::Validations::AssociatedValidator } end |