From 8c8942ed4f2da52aa42ccd46560acb0b5fd37cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 14 Jan 2010 19:53:07 +0100 Subject: Move Dispatcher setup to Railties and add instrumentation hook. --- railties/lib/rails/bootstrap.rb | 21 ++++++++++++++++----- railties/lib/rails/dispatcher.rb | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/bootstrap.rb b/railties/lib/rails/bootstrap.rb index 8a65b3fa98..b7cf70747a 100644 --- a/railties/lib/rails/bootstrap.rb +++ b/railties/lib/rails/bootstrap.rb @@ -80,10 +80,7 @@ module Rails end end - # Sets the logger for Active Record, Action Controller, and Action Mailer - # (but only for those frameworks that are to be loaded). If the framework's - # logger is already set, it is not changed, otherwise it is set to use - # RAILS_DEFAULT_LOGGER. + # Sets the logger for dependencies and cache store. initializer :initialize_framework_logging do ActiveSupport::Dependencies.logger ||= Rails.logger Rails.cache.logger ||= Rails.logger @@ -99,7 +96,7 @@ module Rails # Loads support for "whiny nil" (noisy warnings when methods are invoked # on +nil+ values) if Configuration#whiny_nils is true. initializer :initialize_whiny_nils do - require('active_support/whiny_nil') if config.whiny_nils + require 'active_support/whiny_nil' if config.whiny_nils end # Sets the default value for Time.zone @@ -120,6 +117,8 @@ module Rails # Set the i18n configuration from config.i18n but special-case for the load_path which should be # appended to what's already set instead of overwritten. initializer :initialize_i18n do + require 'active_support/i18n' + config.i18n.each do |setting, value| if setting == :load_path I18n.load_path += value @@ -127,6 +126,18 @@ module Rails I18n.send("#{setting}=", value) end end + + ActionDispatch::Callbacks.to_prepare do + I18n.reload! + end + end + + initializer :set_clear_dependencies_hook do + unless config.cache_classes + ActionDispatch::Callbacks.after do + ActiveSupport::Dependencies.clear + end + end end initializer :initialize_notifications do diff --git a/railties/lib/rails/dispatcher.rb b/railties/lib/rails/dispatcher.rb index 7f9a6221d9..5d383eacd1 100644 --- a/railties/lib/rails/dispatcher.rb +++ b/railties/lib/rails/dispatcher.rb @@ -20,5 +20,5 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -require 'action_controller/dispatch/dispatcher' +require 'action_controller/deprecated/dispatcher' Dispatcher = ActionController::Dispatcher -- cgit v1.2.3