Class: ActionDispatch::MiddlewareStack::Middleware
- Inherits:
-
Object
- Object
- ActionDispatch::MiddlewareStack::Middleware
- Defined in:
- lib/action_dispatch/middleware/stack.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#classcache ⇒ Object
readonly
Returns the value of attribute classcache.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(middleware) ⇒ Object
- #build(app) ⇒ Object
-
#initialize(klass_or_name, *args, &block) ⇒ Middleware
constructor
A new instance of Middleware.
- #inspect ⇒ Object
- #klass ⇒ Object
Constructor Details
#initialize(klass_or_name, *args, &block) ⇒ Middleware
Returns a new instance of Middleware.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/action_dispatch/middleware/stack.rb', line 9 def initialize(klass_or_name, *args, &block) @klass = nil if klass_or_name.respond_to?(:name) @klass = klass_or_name @name = @klass.name else @name = klass_or_name.to_s end @classcache = ActiveSupport::Dependencies::Reference @args, @block = args, block end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
7 8 9 |
# File 'lib/action_dispatch/middleware/stack.rb', line 7 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/action_dispatch/middleware/stack.rb', line 7 def block @block end |
#classcache ⇒ Object (readonly)
Returns the value of attribute classcache.
7 8 9 |
# File 'lib/action_dispatch/middleware/stack.rb', line 7 def classcache @classcache end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/action_dispatch/middleware/stack.rb', line 7 def name @name end |
Instance Method Details
#==(middleware) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/action_dispatch/middleware/stack.rb', line 27 def ==(middleware) case middleware when Middleware klass == middleware.klass when Class klass == middleware else normalize(@name) == normalize(middleware) end end |
#build(app) ⇒ Object
42 43 44 |
# File 'lib/action_dispatch/middleware/stack.rb', line 42 def build(app) klass.new(app, *args, &block) end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/action_dispatch/middleware/stack.rb', line 38 def inspect klass.to_s end |
#klass ⇒ Object
23 24 25 |
# File 'lib/action_dispatch/middleware/stack.rb', line 23 def klass @klass || classcache[@name] end |