Class: Mongoid::Matchers::Validations::ValidateWithCustomValidatorMatcher
Instance Method Summary
collapse
#failure_message_for_should, #failure_message_for_should_not, #on, #with_message
Constructor Details
Returns a new instance of ValidateWithCustomValidatorMatcher.
5
6
7
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 5
def initialize(field)
super(field, :custom)
end
|
Instance Method Details
#description ⇒ Object
21
22
23
24
25
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 21
def description
options_desc = []
options_desc << " with custom validator #{@custom_validator.name}" if @validator
"validate field #{@field.inspect}" << options_desc.to_sentence
end
|
#matches?(actual) ⇒ Boolean
14
15
16
17
18
19
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 14
def matches?(actual)
return false unless (@result = super(actual))
check_custom_validator if @custom_validator
@result
end
|
#with_validator(custom_validator) ⇒ Object
9
10
11
12
|
# File 'lib/matchers/validations/custom_validation_of.rb', line 9
def with_validator(custom_validator)
@custom_validator = custom_validator
self
end
|