Class: ActionDispatch::MiddlewareStack::Middleware

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass_or_name, *args, &block) ⇒ Middleware

Returns a new instance of Middleware.



8
9
10
11
# File '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

#argsObject (readonly)

Returns the value of attribute args.



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

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

Instance Method Details

#==(middleware) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File '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

#build(app) ⇒ Object



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

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

#inspectObject



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

def inspect
  klass.to_s
end

#klassObject



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

def klass
  @ref.get
end