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.
77 78 79 80 |
# File 'lib/dry/validation/executor.rb', line 77 def initialize(final) @steps = [] @final = final end |
Instance Attribute Details
#final ⇒ Object (readonly)
Returns the value of attribute final.
71 72 73 |
# File 'lib/dry/validation/executor.rb', line 71 def final @final end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
71 72 73 |
# File 'lib/dry/validation/executor.rb', line 71 def steps @steps end |
Class Method Details
.new(&block) ⇒ Object
73 74 75 |
# File 'lib/dry/validation/executor.rb', line 73 def self.new(&block) super(BuildErrors.new).tap { |executor| yield(executor.steps) }.freeze end |
Instance Method Details
#call(input, result = {}) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/dry/validation/executor.rb', line 82 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 |