Class: Mongoid::Matchers::Validations::ValidateAcceptanceMatcher
Instance Method Summary
collapse
#failure_message, #negative_failure_message, #with_message
Methods included from Helpers
#class_of, #to_sentence
Constructor Details
Returns a new instance of ValidateAcceptanceMatcher.
5
6
7
|
# File 'lib/matchers/validations/acceptance.rb', line 5
def initialize(field)
super(field, :acceptance)
end
|
Instance Method Details
#accept_with(value) ⇒ Object
9
10
11
12
|
# File 'lib/matchers/validations/acceptance.rb', line 9
def accept_with(value)
@accepted = value
self
end
|
#description ⇒ Object
22
23
24
25
26
|
# File 'lib/matchers/validations/acceptance.rb', line 22
def description
desc = []
desc << " accept with #{@accepted.inspect}" if @accepted
super << desc.to_sentence
end
|
#matches?(subject) ⇒ Boolean
14
15
16
17
18
19
20
|
# File 'lib/matchers/validations/acceptance.rb', line 14
def matches?(subject)
return false unless @result = super(subject)
check_accepted_value if @accepted
@result
end
|