Class: ActionController::MiddlewareStack::Middleware
- Defined in:
- lib/action_controller/middleware_stack.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Class Method Summary collapse
Instance Method Summary collapse
- #==(middleware) ⇒ Object
- #active? ⇒ Boolean
- #build(app) ⇒ Object
-
#initialize(klass, *args, &block) ⇒ Middleware
constructor
A new instance of Middleware.
- #inspect ⇒ Object
- #klass ⇒ Object
Constructor Details
#initialize(klass, *args, &block) ⇒ Middleware
Returns a new instance of Middleware.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/action_controller/middleware_stack.rb', line 14 def initialize(klass, *args, &block) @klass = klass = args. if .has_key?(:if) @conditional = .delete(:if) else @conditional = true end args << unless .empty? @args = args @block = block end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
12 13 14 |
# File 'lib/action_controller/middleware_stack.rb', line 12 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
12 13 14 |
# File 'lib/action_controller/middleware_stack.rb', line 12 def block @block end |
Class Method Details
.new(klass, *args, &block) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/action_controller/middleware_stack.rb', line 4 def self.new(klass, *args, &block) if klass.is_a?(self) klass else super end end |
Instance Method Details
#==(middleware) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/action_controller/middleware_stack.rb', line 51 def ==(middleware) case middleware when Middleware klass == middleware.klass when Class klass == middleware else klass == middleware.to_s.constantize end end |
#active? ⇒ Boolean
41 42 43 44 45 46 47 48 49 |
# File 'lib/action_controller/middleware_stack.rb', line 41 def active? return false unless klass if @conditional.respond_to?(:call) @conditional.call else @conditional end end |
#build(app) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/action_controller/middleware_stack.rb', line 68 def build(app) if block klass.new(app, *build_args, &block) else klass.new(app, *build_args) end end |
#inspect ⇒ Object
62 63 64 65 66 |
# File 'lib/action_controller/middleware_stack.rb', line 62 def inspect str = klass.to_s args.each { |arg| str += ", #{arg.inspect}" } str end |
#klass ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/action_controller/middleware_stack.rb', line 29 def klass if @klass.respond_to?(:call) @klass.call elsif @klass.is_a?(Class) @klass else @klass.to_s.constantize end rescue NameError @klass end |