Module: Messaging::Middleware

Defined in:
lib/messaging/middleware.rb,
lib/messaging/middleware/rails_wrapper.rb,
lib/messaging/middleware/after_active_record_transaction.rb

Defined Under Namespace

Classes: AfterActiveRecordTransaction, RailsWrapper

Class Method Summary collapse

Class Method Details

.run(middlewares, *args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/messaging/middleware.rb', line 3

def self.run(middlewares, *args)
  chain = Array(middlewares.dup)

  call_stack = lambda do
    return yield if chain.empty?

    chain.shift.call(*args, &call_stack)
  end
  call_stack.call
end