2010-12-23 13:20:57 -05:00
|
|
|
require 'active_support/core_ext/module/delegation'
|
|
|
|
|
2009-05-17 14:39:44 -04:00
|
|
|
module ActionDispatch
|
2010-01-14 13:53:07 -05:00
|
|
|
# Provide callbacks to be executed before and after the request dispatch.
|
2009-05-17 14:39:44 -04:00
|
|
|
class Callbacks
|
2009-10-12 23:15:43 -04:00
|
|
|
include ActiveSupport::Callbacks
|
2009-09-20 09:09:08 -04:00
|
|
|
|
2010-06-19 11:51:29 -04:00
|
|
|
define_callbacks :call, :rescuable => true
|
2009-09-20 09:09:08 -04:00
|
|
|
|
2010-12-23 13:20:57 -05:00
|
|
|
class << self
|
|
|
|
delegate :to_prepare, :to_cleanup, :to => "ActionDispatch::Reloader"
|
2009-09-20 09:09:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.before(*args, &block)
|
|
|
|
set_callback(:call, :before, *args, &block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.after(*args, &block)
|
|
|
|
set_callback(:call, :after, *args, &block)
|
|
|
|
end
|
2009-05-17 14:39:44 -04:00
|
|
|
|
2010-12-19 18:58:58 -05:00
|
|
|
def initialize(app, unused = nil)
|
|
|
|
ActiveSupport::Deprecation.warn "Passing a second argument to ActionDispatch::Callbacks.new is deprecated." unless unused.nil?
|
|
|
|
@app = app
|
2009-05-17 14:39:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
2010-06-19 11:51:29 -04:00
|
|
|
_run_call_callbacks do
|
2010-01-15 08:16:52 -05:00
|
|
|
@app.call(env)
|
2009-09-20 09:09:08 -04:00
|
|
|
end
|
2009-05-17 14:39:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|