Class: Dry::Validation::Executor
- Inherits:
-
Object
- Object
- Dry::Validation::Executor
- Defined in:
- lib/dry/validation/executor.rb
Instance Attribute Summary collapse
-
#final ⇒ Object
readonly
Returns the value of attribute final.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Class Method Summary collapse
Instance Method Summary collapse
- #call(input, result = {}) ⇒ Object
-
#initialize(final) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(final) ⇒ Executor
Returns a new instance of Executor.
91 92 93 94 |
# File 'lib/dry/validation/executor.rb', line 91 def initialize(final) @steps = [] @final = final end |
Instance Attribute Details
#final ⇒ Object (readonly)
Returns the value of attribute final.
85 86 87 |
# File 'lib/dry/validation/executor.rb', line 85 def final @final end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
85 86 87 |
# File 'lib/dry/validation/executor.rb', line 85 def steps @steps end |
Class Method Details
.new(path, &block) ⇒ Object
87 88 89 |
# File 'lib/dry/validation/executor.rb', line 87 def self.new(path, &block) super(BuildErrors[path]).tap { |executor| yield(executor.steps) }.freeze end |
Instance Method Details
#call(input, result = {}) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/dry/validation/executor.rb', line 96 def call(input, result = {}) output = steps.reduce(input) do |a, e| return [a, final.(result)] if result.key?(nil) e.call(a, result) end [output, final.(result)] end |