diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile index 305602e57d..28afdb3bd0 100644 --- a/railties/guides/source/initialization.textile +++ b/railties/guides/source/initialization.textile @@ -258,28 +258,23 @@ This file goes on to define some classes that will be automatically loaded using h4. Lazy Hooks -At the top if the +ActiveSupport::Autoload+ module is the +def self.extended+ method: - - - def self.extended(base) - base.extend(LazyLoadHooks) - end - - -This is called when we extend this module into one of our classes or modules, such is the case later on when we call +extend ActiveSupport::LazyLoadHooks+ not only in the +ActiveSupport+ module, but in all of the Railtie modules (+ActiveRecord+ and so on), as well as in a couple of places. - +ActiveSupport::LazyLoadHooks+ is responsible for defining methods used for running hooks that are defined during the initialization process, such as the one defined inside the +active_record.initialize_timezone+ initializer: 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 -When the initializer is ran it defines a +base_hook+ for +ActiveRecord+ and will only run it when +run_base_hooks+ is called, which in the case of Active Record, is ran after the entirety of +activerecord/lib/active_record/base.rb+ has been evaluated. +When the initializer runs it invokes method +on_load+ for +ActiveRecord+ and the block passed to it would be called only when +run_load_hooks+ is called. +When the entirety of +activerecord/lib/active_record/base.rb+ has been evaluated then +run_load_hooks+ is invoked. The very last line of +activerecord/lib/active_record/base.rb+ is: + + +ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base) + h4. +require 'active_support'+ cont'd.