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-4.0.12 lib/messaging/middleware.rb
messaging-4.0.11 lib/messaging/middleware.rb
messaging-4.0.10 lib/messaging/middleware.rb
messaging-4.0.10.pre lib/messaging/middleware.rb
messaging-4.0.9 lib/messaging/middleware.rb
messaging-4.0.8 lib/messaging/middleware.rb
messaging-4.0.7 lib/messaging/middleware.rb
messaging-4.0.6 lib/messaging/middleware.rb
messaging-4.0.5 lib/messaging/middleware.rb
messaging-4.0.4.pre lib/messaging/middleware.rb
messaging-4.0.3.pre lib/messaging/middleware.rb
messaging-4.0.2.pre lib/messaging/middleware.rb
messaging-4.0.1.pre lib/messaging/middleware.rb
messaging-4.0.0.pre lib/messaging/middleware.rb
messaging-3.8.2 lib/messaging/middleware.rb
messaging-3.8.1 lib/messaging/middleware.rb
messaging-3.8.0 lib/messaging/middleware.rb
messaging-3.7.3 lib/messaging/middleware.rb
messaging-3.7.2 lib/messaging/middleware.rb
messaging-3.7.1 lib/messaging/middleware.rb