From 6d6ae0841c94d3c0ce0c91311028ff7396c44a4a Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 7 Oct 2009 15:21:19 -0700 Subject: Start moving the initializers into the application object --- railties/lib/rails/initializer.rb | 42 ++++----------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) (limited to 'railties/lib/rails/initializer.rb') diff --git a/railties/lib/rails/initializer.rb b/railties/lib/rails/initializer.rb index c2d6e1609f..d3e7f934ea 100644 --- a/railties/lib/rails/initializer.rb +++ b/railties/lib/rails/initializer.rb @@ -1,5 +1,7 @@ require "pathname" +require 'active_support/ordered_hash' +require 'rails/initializable' require 'rails/application' require 'rails/railties_path' require 'rails/version' @@ -12,10 +14,6 @@ require 'rails/configuration' RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV) module Rails - # Sanity check to make sure this file is only loaded once - # TODO: Get to the point where this can be removed. - raise "It looks like initializer.rb was required twice" if defined?(Initializer) - class Initializer class Error < StandardError ; end @@ -110,6 +108,8 @@ module Rails default.run(initializer) else Rails.application = Class.new(Application) + # Trigger the initializer + Rails.application.new yield Rails.application.config if block_given? default.config = Rails.application.config default.run @@ -117,26 +117,6 @@ module Rails end end - # Check for valid Ruby version (1.8.2 or 1.8.4 or higher). This is done in an - # external file, so we can use it from the `rails` program as well without duplication. - Initializer.default.add :check_ruby_version do - require 'rails/ruby_version_check' - end - - # Bail if boot.rb is outdated - Initializer.default.add :freak_out_if_boot_rb_is_outdated do - unless defined?(Rails::BOOTSTRAP_VERSION) - abort %{Your config/boot.rb is outdated: Run "rake rails:update".} - end - end - - # Set the $LOAD_PATH based on the value of - # Configuration#load_paths. Duplicates are removed. - Initializer.default.add :set_load_path do - configuration.paths.add_to_load_path - $LOAD_PATH.uniq! - end - # Requires all frameworks specified by the Configuration#frameworks # list. By default, all frameworks (Active Record, Active Support, # Action Pack, Action Mailer, and Active Resource) are loaded. @@ -230,20 +210,6 @@ module Rails end end - # For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the - # multibyte safe operations. Plugin authors supporting other encodings - # should override this behaviour and set the relevant +default_charset+ - # on ActionController::Base. - # - # For Ruby 1.9, UTF-8 is the default internal and external encoding. - Initializer.default.add :initialize_encoding do - if RUBY_VERSION < '1.9' - $KCODE='u' - else - Encoding.default_external = Encoding::UTF_8 - end - end - # This initialization routine does nothing unless :active_record # is one of the frameworks to load (Configuration#frameworks). If it is, # this sets the database configuration from Configuration#database_configuration -- cgit v1.2.3