Class: Sbmt::Outbox::Middleware::Runner
- Inherits:
-
Object
- Object
- Sbmt::Outbox::Middleware::Runner
- Defined in:
- lib/sbmt/outbox/middleware/runner.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(stack) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(stack) ⇒ Runner
Returns a new instance of Runner.
9 10 11 |
# File 'lib/sbmt/outbox/middleware/runner.rb', line 9 def initialize(stack) @stack = stack end |
Instance Attribute Details
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
7 8 9 |
# File 'lib/sbmt/outbox/middleware/runner.rb', line 7 def stack @stack end |
Instance Method Details
#call(*args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sbmt/outbox/middleware/runner.rb', line 13 def call(*args) return yield if stack.empty? chain = stack.map { |i| i.new } traverse_chain = proc do if chain.empty? yield else chain.shift.call(*args, &traverse_chain) end end traverse_chain.call end |