aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-05-03 09:41:40 -0500
committerJoshua Peek <josh@joshpeek.com>2009-05-03 09:41:40 -0500
commitbcc4537f2a0d37fc02d67e9564fa5c9c5555b3d5 (patch)
tree2084bb22890f635239564b508297aa246cfb591a /actionpack/lib
parente0660192806fc1ec8b75654e69211f85c9f1256b (diff)
downloadrails-bcc4537f2a0d37fc02d67e9564fa5c9c5555b3d5.tar.gz
rails-bcc4537f2a0d37fc02d67e9564fa5c9c5555b3d5.tar.bz2
rails-bcc4537f2a0d37fc02d67e9564fa5c9c5555b3d5.zip
Wrap dispatcher callbacks around the whole middleware chain. Kill unnecessary Reloader middleware.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/dispatch/dispatcher.rb45
-rw-r--r--actionpack/lib/action_dispatch.rb1
-rw-r--r--actionpack/lib/action_dispatch/middleware/reloader.rb14
3 files changed, 22 insertions, 38 deletions
diff --git a/actionpack/lib/action_controller/dispatch/dispatcher.rb b/actionpack/lib/action_controller/dispatch/dispatcher.rb
index c0eb359547..cce3b6175d 100644
--- a/actionpack/lib/action_controller/dispatch/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatch/dispatcher.rb
@@ -5,9 +5,9 @@ module ActionController
class << self
def define_dispatcher_callbacks(cache_classes)
unless cache_classes
- unless self.middleware.include?(ActionDispatch::Reloader)
- self.middleware.insert_after(ActionDispatch::Failsafe, ActionDispatch::Reloader)
- end
+ # Development mode callbacks
+ before_dispatch :reload_application
+ after_dispatch :cleanup_application
ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
end
@@ -40,22 +40,11 @@ module ActionController
def run_prepare_callbacks
new.send :run_callbacks, :prepare_dispatch
end
-
- def reload_application
- # Run prepare callbacks before every request in development mode
- run_prepare_callbacks
-
- Routing::Routes.reload
- end
-
- def cleanup_application
- # Cleanup the application before processing the current request.
- ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
- ActiveSupport::Dependencies.clear
- ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
- end
end
+ cattr_accessor :router
+ self.router = Routing::Routes
+
cattr_accessor :middleware
self.middleware = ActionDispatch::MiddlewareStack.new do |middleware|
middlewares = File.join(File.dirname(__FILE__), "middlewares.rb")
@@ -66,21 +55,31 @@ module ActionController
define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
def initialize
- @app = @@middleware.build(lambda { |env| self._call(env) })
+ @app = @@middleware.build(@@router)
freeze
end
def call(env)
- @app.call(env)
- end
-
- def _call(env)
run_callbacks :before_dispatch
- Routing::Routes.call(env)
+ @app.call(env)
ensure
run_callbacks :after_dispatch, :enumerator => :reverse_each
end
+ def reload_application
+ # Run prepare callbacks before every request in development mode
+ run_callbacks :prepare_dispatch
+
+ @@router.reload
+ end
+
+ def cleanup_application
+ # Cleanup the application before processing the current request.
+ ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
+ ActiveSupport::Dependencies.clear
+ ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
+ end
+
def flush_logger
Base.logger.flush
end
diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb
index 5a082fa7e3..c882930e64 100644
--- a/actionpack/lib/action_dispatch.rb
+++ b/actionpack/lib/action_dispatch.rb
@@ -47,7 +47,6 @@ module ActionDispatch
autoload :Failsafe, 'action_dispatch/middleware/failsafe'
autoload :ParamsParser, 'action_dispatch/middleware/params_parser'
- autoload :Reloader, 'action_dispatch/middleware/reloader'
autoload :Rescue, 'action_dispatch/middleware/rescue'
autoload :ShowExceptions, 'action_dispatch/middleware/show_exceptions'
autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
diff --git a/actionpack/lib/action_dispatch/middleware/reloader.rb b/actionpack/lib/action_dispatch/middleware/reloader.rb
deleted file mode 100644
index 67313e30e4..0000000000
--- a/actionpack/lib/action_dispatch/middleware/reloader.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module ActionDispatch
- class Reloader
- def initialize(app)
- @app = app
- end
-
- def call(env)
- ActionController::Dispatcher.reload_application
- @app.call(env)
- ensure
- ActionController::Dispatcher.cleanup_application
- end
- end
-end