Class: Piperator::Builder
- Inherits:
-
Object
- Object
- Piperator::Builder
- Defined in:
- lib/piperator/builder.rb
Overview
Builder is used to provide DSL-based Pipeline building. Using Builder, Pipelines can be built without pipe chaining, which might be easier if some steps need to be included only on specific conditions.
Class Method Summary collapse
-
.dsl_method(method_name) ⇒ Object
Expose a chained method in Pipeline in DSL.
Instance Method Summary collapse
-
#initialize(saved_binding, pipeline = Pipeline.new) ⇒ Builder
constructor
A new instance of Builder.
-
#pipe ⇒ Object
Call Pipeline#pipe given arguments and use the return value as builder state.
-
#to_pipeline ⇒ Pipeline
Return build pipeline.
-
#wrap ⇒ Object
Call Pipeline#wrap given arguments and use the return value as builder state.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object (private)
41 42 43 44 45 46 47 |
# File 'lib/piperator/builder.rb', line 41 def method_missing(method_name, *arguments, &block) if @saved_binding.receiver.respond_to?(method_name, true) @saved_binding.receiver.send(method_name, *arguments, &block) else super end end |
Class Method Details
.dsl_method(method_name) ⇒ Object
Expose a chained method in Pipeline in DSL
18 19 20 21 22 |
# File 'lib/piperator/builder.rb', line 18 def self.dsl_method(method_name) define_method(method_name) do |*arguments| @pipeline = @pipeline.send(method_name, *arguments) end end |
Instance Method Details
#pipe ⇒ Object
Call Pipeline#pipe given arguments and use the return value as builder state.
24 |
# File 'lib/piperator/builder.rb', line 24 dsl_method :pipe |
#to_pipeline ⇒ Pipeline
Return build pipeline
35 36 37 |
# File 'lib/piperator/builder.rb', line 35 def to_pipeline @pipeline end |
#wrap ⇒ Object
Call Pipeline#wrap given arguments and use the return value as builder state.
25 |
# File 'lib/piperator/builder.rb', line 25 dsl_method :wrap |