class method
self.guard_load_hooks
Ruby on Rails edge
Since edgeSignature
self.guard_load_hooks(*components)
Adds a load hook that makes sure the application is initialized before a lazy-loaded component is loaded. The load hook will advise how to use load hooks to defer code until the application is fully loaded.
Parameters
-
componentsrest
Source
# File railties/lib/rails/railtie.rb, line 221
def guard_load_hooks(*components)
components.each do |component|
ActiveSupport.on_load(component) do
if Rails.try(:application) && !Rails.configuration.eager_load && !Rails.application.initialized?
case Rails.configuration.action_on_early_load_hook
when :log
(Rails.logger || ActiveSupport::Logger.new($stdout)).warn <<~MSG
#{Railtie.load_hook_guard_message_for(component)}
Called from:
#{caller.join("\n")}
MSG
when :raise
raise LoadError, Railtie.load_hook_guard_message_for(component)
end
end
end
end
end
Defined in railties/lib/rails/railtie.rb line 221
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Railtie