Class: ActionDispatch::MiddlewareStack::Middleware

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/middleware/stack.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Middleware) initialize(klass_or_name, *args, &block)

A new instance of Middleware



8
9
10
11
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 8

def initialize(klass_or_name, *args, &block)
  @ref = ActiveSupport::Dependencies::Reference.new(klass_or_name)
  @args, @block = args, block
end

Instance Attribute Details

- (Object) args (readonly)

Returns the value of attribute args



6
7
8
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 6

def args
  @args
end

- (Object) block (readonly)

Returns the value of attribute block



6
7
8
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 6

def block
  @block
end

Instance Method Details

- (Object) ==(middleware)



17
18
19
20
21
22
23
24
25
26
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 17

def ==(middleware)
  case middleware
  when Middleware
    klass == middleware.klass
  when Class
    klass == middleware
  else
    normalize(@ref.name) == normalize(middleware)
  end
end

- (Object) build(app)



32
33
34
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 32

def build(app)
  klass.new(app, *args, &block)
end

- (Object) inspect



28
29
30
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 28

def inspect
  klass.to_s
end

- (Object) klass



13
14
15
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 13

def klass
  @ref.get
end