Class: RSchema::Schemas::Pipeline
- Inherits:
-
Object
- Object
- RSchema::Schemas::Pipeline
- Defined in:
- lib/rschema/schemas/pipeline.rb
Overview
A schema that chains together an ordered list of other schemas
Instance Attribute Summary collapse
-
#subschemas ⇒ Object
readonly
Returns the value of attribute subschemas.
Instance Method Summary collapse
- #call(value, options) ⇒ Object
-
#initialize(subschemas) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #with_wrapped_subschemas(wrapper) ⇒ Object
Constructor Details
#initialize(subschemas) ⇒ Pipeline
Returns a new instance of Pipeline.
22 23 24 |
# File 'lib/rschema/schemas/pipeline.rb', line 22 def initialize(subschemas) @subschemas = subschemas end |
Instance Attribute Details
#subschemas ⇒ Object (readonly)
Returns the value of attribute subschemas.
20 21 22 |
# File 'lib/rschema/schemas/pipeline.rb', line 20 def subschemas @subschemas end |
Instance Method Details
#call(value, options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rschema/schemas/pipeline.rb', line 26 def call(value, ) result = Result.success(value) subschemas.each do |subsch| result = subsch.call(result.value, ) break if result.invalid? end result end |
#with_wrapped_subschemas(wrapper) ⇒ Object
37 38 39 40 |
# File 'lib/rschema/schemas/pipeline.rb', line 37 def with_wrapped_subschemas(wrapper) wrapped_subschemas = subschemas.map { |ss| wrapper.wrap(ss) } self.class.new(wrapped_subschemas) end |