diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-04-14 16:21:06 -0500 |
---|---|---|
committer | Carl Lerche & Yehuda Katz <wycats@gmail.com> | 2009-04-14 18:32:31 -0700 |
commit | c2511f936e0129cde898e059391aeaca5a3f238b (patch) | |
tree | 2a3a937f4d536bbaaaef68608eff8374446a96ec | |
parent | d7751036fa0af56b31a1d1350284fa86c0f93971 (diff) | |
download | rails-c2511f936e0129cde898e059391aeaca5a3f238b.tar.gz rails-c2511f936e0129cde898e059391aeaca5a3f238b.tar.bz2 rails-c2511f936e0129cde898e059391aeaca5a3f238b.zip |
Make dispatcher instances immutable
-rw-r--r-- | actionpack/lib/action_controller/dispatch/dispatcher.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/dispatch/dispatcher.rb b/actionpack/lib/action_controller/dispatch/dispatcher.rb index 091cc49412..bb9d8bd063 100644 --- a/actionpack/lib/action_controller/dispatch/dispatcher.rb +++ b/actionpack/lib/action_controller/dispatch/dispatcher.rb @@ -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 |