Make dispatcher instances immutable

This commit is contained in:
Joshua Peek 2009-04-14 16:21:06 -05:00 committed by Carl Lerche & Yehuda Katz
parent d7751036fa
commit c2511f936e
1 changed files with 14 additions and 3 deletions

View File

@ -66,7 +66,8 @@ module ActionController
define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
def initialize
@app = @@middleware.build(lambda { |env| self.dup._call(env) })
@app = @@middleware.build(lambda { |env| self._call(env) })
freeze
end
def call(env)
@ -74,8 +75,18 @@ module ActionController
end
def _call(env)
@env = env
dispatch
begin
run_callbacks :before_dispatch
Routing::Routes.call(env)
rescue Exception => exception
if controller ||= (::ApplicationController rescue Base)
controller.call_with_exception(env, exception).to_a
else
raise exception
end
ensure
run_callbacks :after_dispatch, :enumerator => :reverse_each
end
end
def flush_logger