instance method on_load

Ruby on Rails 7.2.3

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

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

  • :run_once - Given block will run only once.

Parameters

name req
options opt = {}
block block
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

Type at least 2 characters to search.

↑↓ navigate · open · esc close