Permalink
Browse files

Make dispatcher instances immutable

  • Loading branch information...
1 parent d775103 commit c2511f936e0129cde898e059391aeaca5a3f238b @josh josh committed with wycats Apr 14, 2009
Showing with 14 additions and 3 deletions.
  1. +14 −3 actionpack/lib/action_controller/dispatch/dispatcher.rb
View
17 actionpack/lib/action_controller/dispatch/dispatcher.rb
@@ -66,16 +66,27 @@ def cleanup_application
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)
@app.call(env)
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

4 comments on commit c2511f9

@alloy

It’s a bit hard to follow the history how this relates to c1b4a5eb564f8fdd71307efeb5ee729cc6f20059.

Second, where are the tests?

@josh
Ruby on Rails member

Weird git merge issue. I was pretty sure this diff was committed w/ c1b4a5eb.

This is related to removing CGI support. There are no new apis or features we are adding, nothing additional to test.

@josh
Ruby on Rails member

Ah, here is the real commit: c1b4a5eb564f8fdd71307efeb5ee729cc6f20059

@alloy

Thanks for clarifying!

Please sign in to comment.