instance method
on_load
Ruby on Rails 8.1.2
Since v5.2.8.1Signature
on_load(name, options = {}, &block)
Declares a block that will be executed when a Rails component is fully loaded. If the component has already loaded, the block is executed immediately.
Options
-
:yield- Yields the object that run_load_hooks toblock. -
:run_once- Givenblockwill run only once.
Parameters
-
namereq -
optionsopt = {} -
blockblock
Source
# File activesupport/lib/active_support/lazy_load_hooks.rb, line 60
def on_load(name, options = {}, &block)
@loaded[name].each do |base|
execute_hook(name, base, options, block)
end
@load_hooks[name] << [block, options]
end
Defined in activesupport/lib/active_support/lazy_load_hooks.rb line 60
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::LazyLoadHooks