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.
21 22 23 |
# File 'lib/rschema/schemas/pipeline.rb', line 21 def initialize(subschemas) @subschemas = subschemas end |
Instance Attribute Details
#subschemas ⇒ Object (readonly)
Returns the value of attribute subschemas.
19 20 21 |
# File 'lib/rschema/schemas/pipeline.rb', line 19 def subschemas @subschemas end |
Instance Method Details
#call(value, options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rschema/schemas/pipeline.rb', line 25 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
36 37 38 39 |
# File 'lib/rschema/schemas/pipeline.rb', line 36 def with_wrapped_subschemas(wrapper) wrapped_subschemas = subschemas.map{ |ss| wrapper.wrap(ss) } self.class.new(wrapped_subschemas) end |