Class: Dynflow::Middleware::Stack
- Inherits:
-
Object
- Object
- Dynflow::Middleware::Stack
- Includes:
- Algebrick::TypeCheck
- Defined in:
- lib/dynflow/middleware/stack.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#middleware ⇒ Object
readonly
Returns the value of attribute middleware.
-
#middleware_class ⇒ Object
readonly
Returns the value of attribute middleware_class.
Class Method Summary collapse
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(next_stack, middleware_class, method, action) ⇒ Stack
constructor
A new instance of Stack.
- #pass(*args) ⇒ Object
Constructor Details
#initialize(next_stack, middleware_class, method, action) ⇒ Stack
Returns a new instance of Stack.
13 14 15 16 17 18 19 |
# File 'lib/dynflow/middleware/stack.rb', line 13 def initialize(next_stack, middleware_class, method, action) @middleware_class = Child! middleware_class, Middleware @middleware = middleware_class.new self @action = Type! action, Dynflow::Action, NilClass @method = Match! method, :plan, :run, :finalize, :plan_phase, :finalize_phase @next_stack = Type! next_stack, Middleware::Stack, Proc end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
5 6 7 |
# File 'lib/dynflow/middleware/stack.rb', line 5 def action @action end |
#middleware ⇒ Object (readonly)
Returns the value of attribute middleware.
5 6 7 |
# File 'lib/dynflow/middleware/stack.rb', line 5 def middleware @middleware end |
#middleware_class ⇒ Object (readonly)
Returns the value of attribute middleware_class.
5 6 7 |
# File 'lib/dynflow/middleware/stack.rb', line 5 def middleware_class @middleware_class end |
Class Method Details
.build(middleware_classes, method, action, &block) ⇒ Object
7 8 9 10 11 |
# File 'lib/dynflow/middleware/stack.rb', line 7 def self.build(middleware_classes, method, action, &block) middleware_classes.reverse_each.reduce(block) do |stack, klass| Middleware::Stack.new(stack, klass, method, action) end end |
Instance Method Details
#call(*args) ⇒ Object
21 22 23 |
# File 'lib/dynflow/middleware/stack.rb', line 21 def call(*args) @middleware.send @method, *args end |
#pass(*args) ⇒ Object
25 26 27 |
# File 'lib/dynflow/middleware/stack.rb', line 25 def pass(*args) @next_stack.call(*args) end |