Skip to content

Commit

Permalink
Make dispatcher instances immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
josh authored and wycats committed Apr 15, 2009
1 parent d775103 commit c2511f9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions actionpack/lib/action_controller/dispatch/dispatcher.rb
Expand Up @@ -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
Expand Down

4 comments on commit c2511f9

@alloy
Copy link
Contributor

@alloy alloy commented on c2511f9 Apr 15, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Second, where are the tests?

@josh
Copy link
Contributor Author

@josh josh commented on c2511f9 Apr 15, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

@josh josh commented on c2511f9 Apr 15, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, here is the real commit: c1b4a5eb564f8fdd71307efeb5ee729cc6f20059

@alloy
Copy link
Contributor

@alloy alloy commented on c2511f9 Apr 16, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying!

Please sign in to comment.