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.



9
10
11
12
13
# File 'lib/action_dispatch/middleware/stack.rb', line 9

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



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

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#klassObject (readonly)

Returns the value of attribute klass.



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

def klass
  @klass
end

Instance Method Details

#==(middleware) ⇒ Object



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

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

#build(app) ⇒ Object



34
35
36
# File 'lib/action_dispatch/middleware/stack.rb', line 34

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

#inspectObject



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

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

#nameObject



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

def name; klass.name; end