123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::Dependencies

Do not use. This module is for internal use only.

Class Method Summary

Instance Attribute Summary

  • #_autoloaded_tracked_classes rw

    If reloading is enabled, this private set holds autoloaded classes tracked by the descendants tracker.

  • #_eager_load_paths rw

    This is a private set that collects all eager load paths during bootstrap.

  • #autoload_once_paths rw

    The array of directories from which we autoload and never reload, even if reloading is enabled.

  • #autoload_paths rw

    The array of directories from which we autoload and reload, if reloading is enabled.

  • #autoloader rw

    If reloading is enabled, this private attribute stores the main autoloader of a ::Rails application.

  • #interlock rw

Class Method Details

.clear

Private method that reloads constants autoloaded by the main autoloader.

Rails.application.reloader.reload! is the public interface for application reload. That involves more things, like deleting unloaded classes from the internal state of the descendants tracker, or reloading routes.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 76

def self.clear
  unload_interlock do
    _autoloaded_tracked_classes.clear
    autoloader.reload
  end
end

.eager_load?(path) ⇒ Boolean

Private method that helps configuring the autoloaders.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 94

def self.eager_load?(path)
  _eager_load_paths.member?(path)
end

.load_interlock(&block)

Execute the supplied block while holding an exclusive lock, preventing any other thread from being inside a #run_interlock block at the same time.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 24

def self.load_interlock(&block)
  interlock.loading(&block)
end

.run_interlock(&block)

Execute the supplied block without interference from any concurrent loads.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 17

def self.run_interlock(&block)
  interlock.running(&block)
end

.search_for_file(relpath)

Private method used by require_dependency.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 84

def self.search_for_file(relpath)
  relpath += ".rb" unless relpath.end_with?(".rb")
  autoload_paths.each do |autoload_path|
    abspath = File.join(autoload_path, relpath)
    return abspath if File.file?(abspath)
  end
  nil
end

.unload_interlock(&block)

Execute the supplied block while holding an exclusive lock, preventing any other thread from being inside a #run_interlock block at the same time.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 31

def self.unload_interlock(&block)
  interlock.unloading(&block)
end

Instance Attribute Details

#_autoloaded_tracked_classes (rw)

If reloading is enabled, this private set holds autoloaded classes tracked by the descendants tracker. It is populated by an on_load callback in the main autoloader. Used to clear state.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 62

singleton_class.attr_accessor :_autoloaded_tracked_classes

#_eager_load_paths (rw)

This is a private set that collects all eager load paths during bootstrap. Useful for Zeitwerk integration. The public interface to push custom directories to this collection from applications or engines is config.eager_load_paths.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 56

singleton_class.attr_accessor :_eager_load_paths

#autoload_once_paths (rw)

The array of directories from which we autoload and never reload, even if reloading is enabled. The public interface to push directories to this collection from applications or engines is config.autoload_once_paths.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 49

singleton_class.attr_accessor :autoload_once_paths

#autoload_paths (rw)

The array of directories from which we autoload and reload, if reloading is enabled. The public interface to push directories to this collection from applications or engines is config.autoload_paths.

This collection is allowed to have intersection with autoload_once_paths. Common directories are not reloaded.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 43

singleton_class.attr_accessor :autoload_paths

#autoloader (rw)

If reloading is enabled, this private attribute stores the main autoloader of a ::Rails application. It is nil otherwise.

The public interface for this autoloader is Rails.autoloaders.main.

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 69

singleton_class.attr_accessor :autoloader

#interlock (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/dependencies.rb', line 10

singleton_class.attr_accessor :interlock