Class: ActionDispatch::Callbacks
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- actionpack/lib/action_dispatch/middleware/callbacks.rb
Overview
Provide callbacks to be executed before and after the request dispatch.
Constant Summary
Constants included from ActiveSupport::Callbacks
ActiveSupport::Callbacks::CALLBACK_FILTER_TYPES
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Callbacks
constructor
A new instance of Callbacks.
Methods included from ActiveSupport::Callbacks
Methods included from ActiveSupport::Concern
#append_features, extended, #included
Constructor Details
#initialize(app) ⇒ Callbacks
Returns a new instance of Callbacks.
21 22 23 |
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 21 def initialize(app) @app = app end |
Class Method Details
.after(*args, &block) ⇒ Object
17 18 19 |
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 17 def self.after(*args, &block) set_callback(:call, :after, *args, &block) end |
.before(*args, &block) ⇒ Object
13 14 15 |
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 13 def self.before(*args, &block) set_callback(:call, :before, *args, &block) end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 25 def call(env) error = nil result = run_callbacks :call do begin @app.call(env) rescue => error end end raise error if error result end |