Class: Lita::MiddlewareRegistry Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/lita/middleware_registry.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Stores Rack middleware for later use in a Rack::Builder.

Since:

  • 4.0.2

Defined Under Namespace

Classes: MiddlewareWrapper

Instance Method Summary collapse

Constructor Details

#initializeMiddlewareRegistry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MiddlewareRegistry.

Since:

  • 4.0.2



13
14
15
# File 'lib/lita/middleware_registry.rb', line 13

def initialize
  @registry = []
end

Instance Method Details

#push(middleware) ⇒ void Also known as: <<

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Adds a Rack middleware with no initialization arguments.

Parameters:

  • middleware (#call)

    A Rack middleware.

Since:

  • 4.0.2



20
21
22
# File 'lib/lita/middleware_registry.rb', line 20

def push(middleware)
  @registry << MiddlewareWrapper.new(middleware, [], nil)
end

#use(middleware, *args) { ... } ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Adds a Rack middleware with initialization argumens. Uses the same interface as Rack::Builder#use.

Parameters:

  • middleware (#call)

    A Rack middleware.

  • args (Array)

    Arbitrary initialization arguments for the middleware.

Yields:

  • An optional block to be passed to the constructor of the middleware.

Since:

  • 4.0.2



31
32
33
# File 'lib/lita/middleware_registry.rb', line 31

def use(middleware, *args, &block)
  @registry << MiddlewareWrapper.new(middleware, args, block)
end