class ActionDispatch::Callbacks

Parent:
Object
Included modules:
ActiveSupport::Callbacks

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

Public Class Methods

after(*args, &block) Show source
# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 16
def after(*args, &block)
  set_callback(:call, :after, *args, &block)
end
before(*args, &block) Show source
# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 12
def before(*args, &block)
  set_callback(:call, :before, *args, &block)
end
new(app) Show source
# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 21
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) Show source
# 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

© 2004–2016 David Heinemeier Hansson
Licensed under the MIT License.