Class: Easy::Matchers::Validations::ValidatePresenceOfMatcher
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 ValidatePresenceOfMatcher.
9
10
11
|
# File 'lib/matchers/validations/presence_of.rb', line 9
def initialize(attributes)
super(attributes, :presence)
end
|
Instance Method Details
#allow_blank(value = true) ⇒ Object
54
55
56
57
|
# File 'lib/matchers/validations/presence_of.rb', line 54
def allow_blank(value = true)
options[:allow_blank] = value
self
end
|
#allow_nil(value = true) ⇒ Object
49
50
51
52
|
# File 'lib/matchers/validations/presence_of.rb', line 49
def allow_nil(value = true)
options[:allow_nil] = value
self
end
|
#description ⇒ Object
25
26
27
|
# File 'lib/matchers/validations/presence_of.rb', line 25
def description
"require #{ attributes.join(', ') } to be set"
end
|
#if(symbol_name) ⇒ Object
34
35
36
37
|
# File 'lib/matchers/validations/presence_of.rb', line 34
def if(symbol_name)
options[:if] = symbol_name
self
end
|
#matches?(subject) ⇒ Boolean
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/matchers/validations/presence_of.rb', line 13
def matches?(subject)
super(subject)
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
44
45
46
47
|
# File 'lib/matchers/validations/presence_of.rb', line 44
def on(context)
options[:on] = context
self
end
|
#strict(value) ⇒ Object
59
60
61
62
|
# File 'lib/matchers/validations/presence_of.rb', line 59
def strict(value)
options[:strict] = value
self
end
|
#unless(symbol_name) ⇒ Object
39
40
41
42
|
# File 'lib/matchers/validations/presence_of.rb', line 39
def unless(symbol_name)
options[:unless] = symbol_name
self
end
|
#with_message(message) ⇒ Object
29
30
31
32
|
# File 'lib/matchers/validations/presence_of.rb', line 29
def with_message(message)
options[:message] = message
self
end
|