Class: Dry::Validation::ApplyInputRule
- Inherits:
-
Object
- Object
- Dry::Validation::ApplyInputRule
- Defined in:
- lib/dry/validation/executor.rb
Instance Attribute Summary collapse
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
Instance Method Summary collapse
- #call(input, result) ⇒ Object
-
#initialize(rule) ⇒ ApplyInputRule
constructor
A new instance of ApplyInputRule.
Constructor Details
#initialize(rule) ⇒ ApplyInputRule
Returns a new instance of ApplyInputRule.
18 19 20 |
# File 'lib/dry/validation/executor.rb', line 18 def initialize(rule) @rule = rule end |
Instance Attribute Details
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
16 17 18 |
# File 'lib/dry/validation/executor.rb', line 16 def rule @rule end |
Instance Method Details
#call(input, result) ⇒ Object
22 23 24 25 26 |
# File 'lib/dry/validation/executor.rb', line 22 def call(input, result) rule_res = rule.(input) result.update(nil => rule_res) unless rule_res.success? input end |