Sha256: ec2ceca8dd86abc1c91cb61cb9385641dc6e97d52cc0fb8dd3f8f8081df62607

Contents?: true

Size: 274 Bytes

Versions: 34

Compression:

Stored size: 274 Bytes

Contents

module Messaging
  module Middleware
    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
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
messaging-3.7.0 lib/messaging/middleware.rb
messaging-3.6.2 lib/messaging/middleware.rb
messaging-3.6.1 lib/messaging/middleware.rb
messaging-3.6.0 lib/messaging/middleware.rb
messaging-3.5.7 lib/messaging/middleware.rb
messaging-3.5.6 lib/messaging/middleware.rb
messaging-3.5.5 lib/messaging/middleware.rb
messaging-3.5.4 lib/messaging/middleware.rb
messaging-3.5.3 lib/messaging/middleware.rb
messaging-3.5.2 lib/messaging/middleware.rb
messaging-3.5.1 lib/messaging/middleware.rb
messaging-3.4.3 lib/messaging/middleware.rb
messaging-3.4.2 lib/messaging/middleware.rb
messaging-3.4.1 lib/messaging/middleware.rb