diff options
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_controller/railtie.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/active_model_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/railtie.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record.rb | 6 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 16 | ||||
-rw-r--r-- | activesupport/lib/active_support/dependencies/autoload.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/i18n.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/lazy_load_hooks.rb | 30 | ||||
-rw-r--r-- | activesupport/lib/active_support/railtie.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/application/routes_reloader.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 9 |
17 files changed, 48 insertions, 56 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 793cd53518..af7255ae4f 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -291,7 +291,7 @@ module ActionMailer #:nodoc: :parts_order => [ "text/plain", "text/enriched", "text/html" ] }.freeze - ActionMailer.run_base_hooks(self) + ActiveSupport.run_load_hooks(:action_mailer, self) class << self diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 2703367fdb..882e078d1b 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -6,18 +6,18 @@ module ActionMailer config.action_mailer = ActiveSupport::OrderedOptions.new initializer "action_mailer.url_for", :before => :load_environment_config do |app| - ActionMailer.base_hook { include app.routes.url_helpers } + ActiveSupport.on_load(:action_mailer) { include app.routes.url_helpers } end require "action_mailer/railties/log_subscriber" log_subscriber :action_mailer, ActionMailer::Railties::LogSubscriber.new initializer "action_mailer.logger" do - ActionMailer.base_hook { self.logger ||= Rails.logger } + ActiveSupport.on_load(:action_mailer) { self.logger ||= Rails.logger } end initializer "action_mailer.set_configs" do |app| - ActionMailer.base_hook do + ActiveSupport.on_load(:action_mailer) do app.config.action_mailer.each do |k,v| send "#{k}=", v end diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 5797282b41..46a175d2fa 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -64,8 +64,7 @@ module ActionController filter end - ActionController.run_base_hooks(self) - + ActiveSupport.run_load_hooks(:action_controller, self) end end diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 0ec89928af..29d8523ee1 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -41,7 +41,7 @@ module ActionController log_subscriber :action_controller, ActionController::Railties::LogSubscriber.new initializer "action_controller.logger" do - ActionController.base_hook { self.logger ||= Rails.logger } + ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger } end initializer "action_controller.set_configs" do |app| @@ -53,23 +53,23 @@ module ActionController ac.stylesheets_dir = paths.public.stylesheets.to_a.first ac.secret = app.config.cookie_secret - ActionController.base_hook do + ActiveSupport.on_load(:action_controller) do self.config.merge!(ac) end end initializer "action_controller.initialize_framework_caches" do - ActionController.base_hook { self.cache_store ||= RAILS_CACHE } + ActiveSupport.on_load(:action_controller) { self.cache_store ||= RAILS_CACHE } end initializer "action_controller.set_helpers_path" do |app| - ActionController.base_hook do + ActiveSupport.on_load(:action_controller) do self.helpers_path = app.config.paths.app.helpers.to_a end end initializer "action_controller.url_helpers" do |app| - ActionController.base_hook do + ActiveSupport.on_load(:action_controller) do extend ::ActionController::Railties::UrlHelpers.with(app.routes) end diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 919b1e3470..a9b0715b2e 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -173,7 +173,7 @@ module ActionView #:nodoc: delegate :logger, :to => 'ActionController::Base', :allow_nil => true end - ActionView.run_base_hooks(self) + ActiveSupport.run_load_hooks(:action_view, self) attr_accessor :base_path, :assigns, :template_extension, :lookup_context attr_internal :captures, :request, :controller, :template, :config diff --git a/actionpack/lib/action_view/helpers/active_model_helper.rb b/actionpack/lib/action_view/helpers/active_model_helper.rb index bbfac32322..44e193f18e 100644 --- a/actionpack/lib/action_view/helpers/active_model_helper.rb +++ b/actionpack/lib/action_view/helpers/active_model_helper.rb @@ -6,7 +6,7 @@ require 'active_support/core_ext/kernel/reporting' require 'active_support/core_ext/object/blank' module ActionView - ActionView.base_hook do + ActiveSupport.on_load(:action_view) do class ActionView::Base @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"fieldWithErrors\">#{html_tag}</div>".html_safe } cattr_accessor :field_error_proc diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 7b5b3ae000..89560d0b49 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -1221,7 +1221,7 @@ module ActionView end end - ActionView.base_hook do + ActiveSupport.on_load(:action_view) do class ActionView::Base cattr_accessor :default_form_builder @@default_form_builder = ::ActionView::Helpers::FormBuilder diff --git a/actionpack/lib/action_view/railtie.rb b/actionpack/lib/action_view/railtie.rb index 9cf007cd2b..c606a71e18 100644 --- a/actionpack/lib/action_view/railtie.rb +++ b/actionpack/lib/action_view/railtie.rb @@ -10,14 +10,14 @@ module ActionView initializer "action_view.cache_asset_timestamps" do |app| unless app.config.cache_classes - ActionView.base_hook do + ActiveSupport.on_load(:action_view) do ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false end end end initializer "action_view.set_configs" do |app| - ActionView.base_hook do + ActiveSupport.on_load(:action_view) do app.config.action_view.each do |k,v| send "#{k}=", v end diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index 5942640c85..8a1aa50e24 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -111,10 +111,10 @@ module ActiveRecord autoload :TestCase autoload :TestFixtures, 'active_record/fixtures' +end - base_hook do - Arel::Table.engine = Arel::Sql::Engine.new(self) - end +ActiveSupport.on_load(:active_record) do + Arel::Table.engine = Arel::Sql::Engine.new(self) end I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml'
\ No newline at end of file diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 80f8569644..75576f146a 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2245,4 +2245,4 @@ end # TODO: Remove this and make it work with LAZY flag require 'active_record/connection_adapters/abstract_adapter' -ActiveRecord.run_base_hooks(ActiveRecord::Base) +ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base) diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index de47461c73..04c4a9c153 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -23,18 +23,18 @@ module ActiveRecord log_subscriber :active_record, ActiveRecord::Railties::LogSubscriber.new initializer "active_record.initialize_timezone" do - ActiveRecord.base_hook do + ActiveSupport.on_load(:active_record) do self.time_zone_aware_attributes = true self.default_timezone = :utc end end initializer "active_record.logger" do - ActiveRecord.base_hook { self.logger ||= ::Rails.logger } + ActiveSupport.on_load(:active_record) { self.logger ||= ::Rails.logger } end initializer "active_record.set_configs" do |app| - ActiveRecord.base_hook do + ActiveSupport.on_load(:active_record) do app.config.active_record.each do |k,v| send "#{k}=", v end @@ -44,7 +44,7 @@ module ActiveRecord # This sets the database configuration from Configuration#database_configuration # and then establishes the connection. initializer "active_record.initialize_database" do |app| - ActiveRecord.base_hook do + ActiveSupport.on_load(:active_record) do self.configurations = app.config.database_configuration establish_connection end @@ -53,7 +53,7 @@ module ActiveRecord # Expose database runtime to controller for logging. initializer "active_record.log_runtime" do |app| require "active_record/railties/controller_runtime" - ActionController.base_hook do + ActiveSupport.on_load(:action_controller) do include ActiveRecord::Railties::ControllerRuntime end end @@ -71,9 +71,9 @@ module ActiveRecord end initializer "active_record.load_observers" do - ActiveRecord.base_hook { instantiate_observers } + ActiveSupport.on_load(:active_record) { instantiate_observers } - ActiveRecord.base_hook do + ActiveSupport.on_load(:active_record) do ActionDispatch::Callbacks.to_prepare(:activerecord_instantiate_observers) do ActiveRecord::Base.instantiate_observers end @@ -81,7 +81,7 @@ module ActiveRecord end initializer "active_record.set_dispatch_hooks", :before => :set_clear_dependencies_hook do |app| - ActiveRecord.base_hook do + ActiveSupport.on_load(:active_record) do unless app.config.cache_classes ActionDispatch::Callbacks.after do ActiveRecord::Base.reset_subclasses diff --git a/activesupport/lib/active_support/dependencies/autoload.rb b/activesupport/lib/active_support/dependencies/autoload.rb index f669f4a77e..4c771da096 100644 --- a/activesupport/lib/active_support/dependencies/autoload.rb +++ b/activesupport/lib/active_support/dependencies/autoload.rb @@ -3,10 +3,6 @@ require "active_support/lazy_load_hooks" module ActiveSupport module Autoload - def self.extended(base) - base.extend(LazyLoadHooks) - end - @@autoloads = {} @@under_path = nil @@at_path = nil diff --git a/activesupport/lib/active_support/i18n.rb b/activesupport/lib/active_support/i18n.rb index 034d7d8ddc..11af48d67e 100644 --- a/activesupport/lib/active_support/i18n.rb +++ b/activesupport/lib/active_support/i18n.rb @@ -1,3 +1,3 @@ require 'i18n' I18n.load_path << "#{File.dirname(__FILE__)}/locale/en.yml" -ActiveSupport.run_base_hooks(:i18n)
\ No newline at end of file +ActiveSupport.run_load_hooks(:i18n)
\ No newline at end of file diff --git a/activesupport/lib/active_support/lazy_load_hooks.rb b/activesupport/lib/active_support/lazy_load_hooks.rb index 36acfda524..642a4c105c 100644 --- a/activesupport/lib/active_support/lazy_load_hooks.rb +++ b/activesupport/lib/active_support/lazy_load_hooks.rb @@ -1,25 +1,17 @@ module ActiveSupport - module LazyLoadHooks - def _setup_base_hooks - @base_hooks ||= Hash.new {|h,k| h[k] = [] } - @base ||= {} - end - - def base_hook(name = nil, &block) - _setup_base_hooks + @load_hooks = Hash.new {|h,k| h[k] = [] } + @loaded = {} - if base = @base[name] - base.instance_eval(&block) - else - @base_hooks[name] << block - end + def self.on_load(name, &block) + if base = @loaded[name] + base.instance_eval(&block) + else + @load_hooks[name] << block end + end - def run_base_hooks(base, name = nil) - _setup_base_hooks - - @base_hooks[name].each { |hook| base.instance_eval(&hook) } if @base_hooks - @base[name] = base - end + def self.run_load_hooks(name, base = Object) + @load_hooks[name].each { |hook| base.instance_eval(&hook) } + @loaded[name] = base end end
\ No newline at end of file diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index e45d16ee96..b8d54ff839 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -35,7 +35,7 @@ module I18n config.i18n.load_path = [] initializer "i18n.initialize" do - ActiveSupport.base_hook(:i18n) do + ActiveSupport.on_load(:i18n) do I18n.reload! ActionDispatch::Callbacks.to_prepare do diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index a5154f4bba..a2b3622df8 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -27,7 +27,7 @@ module Rails routes.clear! paths.each { |path| load(path) } - ActionController.base_hook { routes.finalize! } + ActiveSupport.on_load(:action_controller) { routes.finalize! } nil ensure diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 85cae75bce..e9013348b5 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -180,8 +180,13 @@ module Rails initializer :add_view_paths do views = paths.app.views.to_a - ActionController.base_hook { prepend_view_path(views) } if defined?(ActionController) - ActionMailer.base_hook { prepend_view_path(views) } if defined?(ActionMailer) + ActiveSupport.on_load(:action_controller) do + prepend_view_path(views) + end + + ActiveSupport.on_load(:action_mailer) do + prepend_view_path(views) + end end initializer :add_metals do |app| |