Class: Pipeline::Builder
- Inherits:
-
Object
- Object
- Pipeline::Builder
- Defined in:
- lib/pipeline/builder.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
Calls the operations in the stack.
-
#initialize(&block) ⇒ Builder
constructor
A new instance of Builder.
-
#inspect_stack ⇒ Object
Returns the internal stack array for reading as a frozen object.
-
#use(operation, *args, &block) ⇒ Object
Adds an operation to the internal stack.
Constructor Details
#initialize(&block) ⇒ Builder
Returns a new instance of Builder.
3 4 5 6 7 8 9 10 11 |
# File 'lib/pipeline/builder.rb', line 3 def initialize(&block) if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Method Details
#call(env) ⇒ Object
Calls the operations in the stack
24 25 26 27 |
# File 'lib/pipeline/builder.rb', line 24 def call(env) build_operation_chain(stack.dup). call(env.dup) end |
#inspect_stack ⇒ Object
Returns the internal stack array for reading as a frozen object
30 31 32 |
# File 'lib/pipeline/builder.rb', line 30 def inspect_stack stack.freeze end |
#use(operation, *args, &block) ⇒ Object
Adds an operation to the internal stack
17 18 19 20 |
# File 'lib/pipeline/builder.rb', line 17 def use(operation, *args, &block) stack << [operation, args, block] self end |