Browse files

updating documentation about lazy hooks in ActiveSupport

  • Loading branch information...
1 parent e429453 commit a506d5a5241507afda5f57ca8953fbcbf4b91231 Neeraj Singh committed Jul 29, 2010
Showing with 7 additions and 12 deletions.
  1. +7 −12 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
-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.

0 comments on commit a506d5a

Please sign in to comment.