Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that load hooks run if already triggered [ci skip] #45453

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion activesupport/lib/active_support/lazy_load_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,7 +48,8 @@ def self.extended(base) # :nodoc:
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:
#
Expand Down