aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-13 09:25:12 +0100
committerJosé Valim <jose.valim@gmail.com>2011-12-13 09:29:18 +0100
commit693d2be82706d7dc40af6860a26330c49c27f151 (patch)
tree0f8d5b7c4f7eeb447c86aa41460c3cdc16720b9f /railties/lib/rails/application
parentcd3033eb627f408b71a7adf98c350e2c01115c33 (diff)
downloadrails-693d2be82706d7dc40af6860a26330c49c27f151.tar.gz
rails-693d2be82706d7dc40af6860a26330c49c27f151.tar.bz2
rails-693d2be82706d7dc40af6860a26330c49c27f151.zip
Move hooks back to initializers (we need an API that allows hooks to be replaced).
Diffstat (limited to 'railties/lib/rails/application')
-rw-r--r--railties/lib/rails/application/finisher.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb
index 3a94311b57..738fb93994 100644
--- a/railties/lib/rails/application/finisher.rb
+++ b/railties/lib/rails/application/finisher.rb
@@ -62,14 +62,31 @@ module Rails
# Set app reload just after the finisher hook to ensure
# routes added in the hook are still loaded.
- initializer :set_routes_reloader_hook do |app|
- app.set_routes_reloader_hook
+ initializer :set_routes_reloader_hook do
+ reloader = routes_reloader
+ hook = lambda { reloader.execute_if_updated }
+ hook.call
+ self.reloaders << reloader
+ ActionDispatch::Reloader.to_prepare(&hook)
end
# Set app reload just after the finisher hook to ensure
# paths added in the hook are still loaded.
- initializer :set_dependencies_hook, :group => :all do |app|
- app.set_dependencies_hook
+ initializer :set_dependencies_hook, :group => :all do
+ callback = lambda do
+ ActiveSupport::DescendantsTracker.clear
+ ActiveSupport::Dependencies.clear
+ end
+
+ if config.reload_classes_only_on_change
+ reloader = config.file_watcher.new(watchable_args, true, &callback)
+ self.reloaders << reloader
+ # We need to set a to_prepare callback regardless of the reloader result, i.e.
+ # models should be reloaded if any of the reloaders (i18n, routes) were updated.
+ ActionDispatch::Reloader.to_prepare(:prepend => true, &callback)
+ else
+ ActionDispatch::Reloader.to_cleanup(&callback)
+ end
end
# Disable dependency loading during request cycle