Class: Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher
- Inherits:
-
ValidateBase
- Object
- ValidateBase
- Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher
- Defined in:
- lib/mongoa/mongo_mapper/validations/validate_inclusion_of.rb
Instance Attribute Summary
Attributes inherited from ValidateBase
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(attribute, within) ⇒ ValidateInclusionOfMatcher
constructor
A new instance of ValidateInclusionOfMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(attribute, within) ⇒ ValidateInclusionOfMatcher
Returns a new instance of ValidateInclusionOfMatcher.
5 6 7 8 |
# File 'lib/mongoa/mongo_mapper/validations/validate_inclusion_of.rb', line 5 def initialize(attribute, within) super(attribute) @within = within end |
Instance Method Details
#description ⇒ Object
15 16 17 |
# File 'lib/mongoa/mongo_mapper/validations/validate_inclusion_of.rb', line 15 def description "require #{@attribute} to be within #{@within}" end |
#failure_message ⇒ Object
19 20 21 |
# File 'lib/mongoa/mongo_mapper/validations/validate_inclusion_of.rb', line 19 def "Expected #{@attribute} to be within #{@within} but was not" end |
#matches?(subject) ⇒ Boolean
10 11 12 13 |
# File 'lib/mongoa/mongo_mapper/validations/validate_inclusion_of.rb', line 10 def matches?(subject) super(subject) @validation ? within == @within : false end |
#negative_failure_message ⇒ Object
23 24 25 |
# File 'lib/mongoa/mongo_mapper/validations/validate_inclusion_of.rb', line 23 def "Expected #{@attribute} to not be within #{@within} but was" end |