mirror of https://github.com/rails/rails
Document that load hooks run if already triggered
After first learning of this in c2a3ff0
and later discussion about cross
component dependencies, it makes sense to document it explicitly.
This commit is contained in:
parent
9badb0f794
commit
31d2468a25
|
@ -26,6 +26,18 @@ module ActiveSupport
|
|||
# run_load_hooks will then execute all the hooks that were registered
|
||||
# with the on_load method. In the case of the above example, it will
|
||||
# execute the block of code that is in the +initializer+.
|
||||
#
|
||||
# Registering a hook that has already run results in that hook executing
|
||||
# immediately. This allows hooks to be nested for code that relies on
|
||||
# multiple lazily loaded components:
|
||||
#
|
||||
# initializer "action_text.renderer" do
|
||||
# ActiveSupport.on_load(:action_controller_base) do
|
||||
# ActiveSupport.on_load(:action_text_content) do
|
||||
# self.default_renderer = Class.new(ActionController::Base).renderer
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
module LazyLoadHooks
|
||||
def self.extended(base) # :nodoc:
|
||||
base.class_eval do
|
||||
|
@ -36,7 +48,8 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
# Declares a block that will be executed when a Rails component is fully
|
||||
# loaded.
|
||||
# loaded. If the component has already loaded, the block is executed
|
||||
# immediately.
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue