Class: ActionDispatch::Callbacks
- Inherits:
-
Object
- Object
- ActionDispatch::Callbacks
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/action_dispatch/middleware/callbacks.rb
Overview
# Action Dispatch Callbacks
Provides callbacks to be executed before and after dispatching the request.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Callbacks
constructor
A new instance of Callbacks.
Constructor Details
#initialize(app) ⇒ Callbacks
Returns a new instance of Callbacks.
24 25 26 |
# File 'lib/action_dispatch/middleware/callbacks.rb', line 24 def initialize(app) @app = app end |
Class Method Details
.after(*args, &block) ⇒ Object
19 20 21 |
# File 'lib/action_dispatch/middleware/callbacks.rb', line 19 def after(*args, &block) set_callback(:call, :after, *args, &block) end |
.before(*args, &block) ⇒ Object
15 16 17 |
# File 'lib/action_dispatch/middleware/callbacks.rb', line 15 def before(*args, &block) set_callback(:call, :before, *args, &block) end |
Instance Method Details
#call(env) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/action_dispatch/middleware/callbacks.rb', line 28 def call(env) error = nil result = run_callbacks :call do @app.call(env) rescue => error end raise error if error result end |