Class: MiniDefender::Rules::DeclinedIf
- Inherits:
-
Declined
- Object
- MiniDefender::Rule
- Declined
- MiniDefender::Rules::DeclinedIf
- Defined in:
- lib/mini_defender/rules/declined_if.rb
Constant Summary
Constants inherited from Declined
MiniDefender::Rules::Declined::ALLOWED_VALUES
Class Method Summary collapse
Instance Method Summary collapse
- #active?(validator) ⇒ Boolean
-
#initialize(target, value) ⇒ DeclinedIf
constructor
A new instance of DeclinedIf.
Methods inherited from Declined
Methods inherited from MiniDefender::Rule
available?, #bails?, #coerce, #default_value, #defaults?, #error_message, #excluded?, #force_coerce?, #implicit?, #message, #passes?, #priority, #stops?, #with_message
Constructor Details
#initialize(target, value) ⇒ DeclinedIf
Returns a new instance of DeclinedIf.
6 7 8 9 10 11 |
# File 'lib/mini_defender/rules/declined_if.rb', line 6 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
17 18 19 20 21 |
# File 'lib/mini_defender/rules/declined_if.rb', line 17 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
13 14 15 |
# File 'lib/mini_defender/rules/declined_if.rb', line 13 def self.signature 'declined_if' end |
Instance Method Details
#active?(validator) ⇒ Boolean
23 24 25 |
# File 'lib/mini_defender/rules/declined_if.rb', line 23 def active?(validator) validator.data[@target] == @value end |