Class: QueueBus::Middleware::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/queue_bus/middleware.rb

Overview

Runs the middleware stack by passing it self to each class.

Instance Method Summary collapse

Constructor Details

#initialize(args:, stack:, inner:) ⇒ Runner

Returns a new instance of Runner.



37
38
39
40
41
# File 'lib/queue_bus/middleware.rb', line 37

def initialize(args:, stack:, inner:)
  @stack = stack
  @inner = inner
  @args = args
end

Instance Method Details

#callObject



43
44
45
46
47
48
49
50
51
# File 'lib/queue_bus/middleware.rb', line 43

def call
  middleware = @stack.shift

  if middleware
    middleware.new(self).call(@args)
  else
    @inner.call
  end
end