Class: MiniDefender::Rules::ExcludedIf
Class Method Summary
collapse
Instance Method Summary
collapse
#active?, available?, #bails?, #coerce, #default_value, #defaults?, #error_message, #force_coerce?, #implicit?, #message, #priority, #stops?, #with_message
Constructor Details
#initialize(target, value) ⇒ ExcludedIf
Returns a new instance of ExcludedIf.
4
5
6
7
8
9
|
# File 'lib/mini_defender/rules/excluded_if.rb', line 4
def initialize(target, value)
raise ArgumentError, 'Target must be a string' unless target.is_a?(String)
@target = target
@value = value
end
|
Class Method Details
.make(args) ⇒ Object
15
16
17
18
19
|
# File 'lib/mini_defender/rules/excluded_if.rb', line 15
def self.make(args)
raise ArgumentError, 'Target and expected value are required.' unless args.length == 2
self.new(args[0], args[1])
end
|
.signature ⇒ Object
11
12
13
|
# File 'lib/mini_defender/rules/excluded_if.rb', line 11
def self.signature
'excluded_if'
end
|
Instance Method Details
#excluded?(validator) ⇒ Boolean
21
22
23
|
# File 'lib/mini_defender/rules/excluded_if.rb', line 21
def excluded?(validator)
validator.data.key?(@target) && validator.data[@target] == @value
end
|
#passes?(attribute, value, validator) ⇒ Boolean
25
26
27
|
# File 'lib/mini_defender/rules/excluded_if.rb', line 25
def passes?(attribute, value, validator)
true
end
|