Class: TTY::Option::Pipeline
- Inherits:
-
Object
- Object
- TTY::Option::Pipeline
- Defined in:
- lib/tty/option/pipeline.rb
Constant Summary collapse
- PROCESSORS =
[ ParamConversion, ParamPermitted, ParamValidation ].freeze
Instance Method Summary collapse
-
#call(param, value) ⇒ Object
Process param value through conditions.
-
#initialize(error_aggregator) ⇒ Pipeline
constructor
private
Create a param processing pipeline.
Constructor Details
#initialize(error_aggregator) ⇒ Pipeline
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a param processing pipeline
19 20 21 |
# File 'lib/tty/option/pipeline.rb', line 19 def initialize(error_aggregator) @error_aggregator = error_aggregator end |
Instance Method Details
#call(param, value) ⇒ Object
Process param value through conditions
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tty/option/pipeline.rb', line 26 def call(param, value) result = Result.success(value) PROCESSORS.each do |processor| result = processor[param, result.value] if result.failure? Array(result.error).each { |err| @error_aggregator.(err) } end end result.value end |