Class: Easy::Matchers::Validations::ValidateAcceptanceOfMatcher
Instance Attribute Summary
#attributes, #failure_message, #failure_message_when_negated, #options, #subject, #type
Instance Method Summary
collapse
#class_name
Constructor Details
Returns a new instance of ValidateAcceptanceOfMatcher.
9
10
11
|
# File 'lib/matchers/validations/acceptance_of.rb', line 9
def initialize(attributes)
super(attributes, :acceptance)
end
|
Instance Method Details
#allow_blank(value = true) ⇒ Object
56
57
58
59
|
# File 'lib/matchers/validations/acceptance_of.rb', line 56
def allow_blank(value = true)
options[:allow_blank] = value
self
end
|
#allow_nil(value = true) ⇒ Object
51
52
53
54
|
# File 'lib/matchers/validations/acceptance_of.rb', line 51
def allow_nil(value = true)
options[:allow_nil] = value
self
end
|
#description ⇒ Object
27
28
29
|
# File 'lib/matchers/validations/acceptance_of.rb', line 27
def description
"require #{ attributes.join(', ') } to be accepted"
end
|
#if(symbol_name) ⇒ Object
36
37
38
39
|
# File 'lib/matchers/validations/acceptance_of.rb', line 36
def if(symbol_name)
options[:if] = symbol_name
self
end
|
#matches?(subject) ⇒ Boolean
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/matchers/validations/acceptance_of.rb', line 13
def matches?(subject)
super(subject)
add_allow_nil_and_accept_to_options
matched_validator = class_name.validators.detect do |validator|
validator.kind == type &&
validator.attributes.sort == attributes.sort &&
validator.options.sort == options.sort
end
true if matched_validator
end
|
#on(context) ⇒ Object
46
47
48
49
|
# File 'lib/matchers/validations/acceptance_of.rb', line 46
def on(context)
options[:on] = context
self
end
|
#strict(value) ⇒ Object
61
62
63
64
|
# File 'lib/matchers/validations/acceptance_of.rb', line 61
def strict(value)
options[:strict] = value
self
end
|
#unless(symbol_name) ⇒ Object
41
42
43
44
|
# File 'lib/matchers/validations/acceptance_of.rb', line 41
def unless(symbol_name)
options[:unless] = symbol_name
self
end
|
#with_message(message) ⇒ Object
31
32
33
34
|
# File 'lib/matchers/validations/acceptance_of.rb', line 31
def with_message(message)
options[:message] = message
self
end
|