Class: Dry::Validation::Rule::Negation
- Inherits:
-
Dry::Validation::Rule
- Object
- Dry::Validation::Rule
- Dry::Validation::Rule::Negation
- Defined in:
- lib/dry/validation/rule.rb
Instance Attribute Summary collapse
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
Attributes inherited from Dry::Validation::Rule
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(rule) ⇒ Negation
constructor
A new instance of Negation.
- #to_ary ⇒ Object
Methods inherited from Dry::Validation::Rule
#and, #curry, #negation, #new, #or, #predicate_id, #then, #type, #xor
Constructor Details
#initialize(rule) ⇒ Negation
Returns a new instance of Negation.
13 14 15 |
# File 'lib/dry/validation/rule.rb', line 13 def initialize(rule) @rule = rule end |
Instance Attribute Details
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
11 12 13 |
# File 'lib/dry/validation/rule.rb', line 11 def rule @rule end |
Instance Method Details
#call(*args) ⇒ Object
17 18 19 |
# File 'lib/dry/validation/rule.rb', line 17 def call(*args) rule.(*args).negated end |
#to_ary ⇒ Object
21 22 23 |
# File 'lib/dry/validation/rule.rb', line 21 def to_ary [:not, rule.to_ary] end |