Method: ActiveSupport::LazyLoadHooks#on_load

Defined in:
activesupport/lib/active_support/lazy_load_hooks.rb

#on_load(name, options = {}, &block) ⇒ Object

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 to block.

  • :run_once - Given block will run only once.



60
61
62
63
64
65
66
# 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