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.



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

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



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

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#klassObject (readonly)

Returns the value of attribute klass.



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

def klass
  @klass
end

Instance Method Details

#==(middleware) ⇒ Object



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

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

#build(app) ⇒ Object



41
42
43
# File 'lib/action_dispatch/middleware/stack.rb', line 41

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

#build_instrumented(app) ⇒ Object



45
46
47
# File 'lib/action_dispatch/middleware/stack.rb', line 45

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

#inspectObject



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

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

#nameObject



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

def name; klass.name; end