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, args, block) ⇒ Middleware

Returns a new instance of Middleware.



18
19
20
21
22
# File 'lib/action_dispatch/middleware/stack.rb', line 18

def initialize(klass, args, block)
  @klass = klass
  @args  = args
  @block = block
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



16
17
18
# File 'lib/action_dispatch/middleware/stack.rb', line 16

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



16
17
18
# File 'lib/action_dispatch/middleware/stack.rb', line 16

def block
  @block
end

#klassObject (readonly)

Returns the value of attribute klass.



16
17
18
# File 'lib/action_dispatch/middleware/stack.rb', line 16

def klass
  @klass
end

Instance Method Details

#==(middleware) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/action_dispatch/middleware/stack.rb', line 26

def ==(middleware)
  case middleware
  when Middleware
    klass == middleware.klass
  when Module
    klass == middleware
  end
end

#build(app) ⇒ Object



43
44
45
# File 'lib/action_dispatch/middleware/stack.rb', line 43

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

#build_instrumented(app) ⇒ Object



47
48
49
# File 'lib/action_dispatch/middleware/stack.rb', line 47

def build_instrumented(app)
  InstrumentationProxy.new(build(app), inspect)
end

#inspectObject



35
36
37
38
39
40
41
# File 'lib/action_dispatch/middleware/stack.rb', line 35

def inspect
  if klass.is_a?(Module)
    klass.to_s
  else
    klass.class.to_s
  end
end

#nameObject



24
# File 'lib/action_dispatch/middleware/stack.rb', line 24

def name; klass.name; end