Class: ActionDispatch::Callbacks

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Callbacks
Defined in:
actionpack/lib/action_dispatch/middleware/callbacks.rb

Overview

Provide callbacks to be executed before and after the request dispatch.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveSupport::Callbacks

#run_callbacks

Methods included from ActiveSupport::Concern

#append_features, extended, #included

Constructor Details

#initialize(app) ⇒ Callbacks

Returns a new instance of Callbacks.



22
23
24
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 22

def initialize(app)
  @app = app
end

Class Method Details

.after(*args, &block) ⇒ Object



18
19
20
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 18

def self.after(*args, &block)
  set_callback(:call, :after, *args, &block)
end

.before(*args, &block) ⇒ Object



14
15
16
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 14

def self.before(*args, &block)
  set_callback(:call, :before, *args, &block)
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
# File 'actionpack/lib/action_dispatch/middleware/callbacks.rb', line 26

def call(env)
  run_callbacks :call do
    @app.call(env)
  end
end