Module: ActiveSupport::Dependencies
- Defined in:
 - lib/active_support/dependencies.rb,
lib/active_support/dependencies/interlock.rb 
Overview
:nodoc:
Defined Under Namespace
Modules: RequireDependency Classes: Interlock
Instance Attribute Summary collapse
- 
  
    
      #_autoloaded_tracked_classes  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
If reloading is enabled, this private set holds autoloaded classes tracked by the descendants tracker.
 - 
  
    
      #_eager_load_paths  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
This is a private set that collects all eager load paths during bootstrap.
 - 
  
    
      #autoload_once_paths  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The array of directories from which we autoload and never reload, even if reloading is enabled.
 - 
  
    
      #autoload_paths  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The array of directories from which we autoload and reload, if reloading is enabled.
 - 
  
    
      #autoloader  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
If reloading is enabled, this private attribute stores the main autoloader of a Rails application.
 - 
  
    
      #interlock  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute interlock.
 
Class Method Summary collapse
- 
  
    
      .clear  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Private method that reloads constants autoloaded by the main autoloader.
 - 
  
    
      .eager_load?(path)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Private method that helps configuring the autoloaders.
 - 
  
    
      .load_interlock(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Execute the supplied block while holding an exclusive lock, preventing any other thread from being inside a #run_interlock block at the same time.
 - 
  
    
      .run_interlock(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Execute the supplied block without interference from any concurrent loads.
 - 
  
    
      .search_for_file(relpath)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Private method used by require_dependency.
 - 
  
    
      .unload_interlock(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Execute the supplied block while holding an exclusive lock, preventing any other thread from being inside a #run_interlock block at the same time.
 
Instance Attribute Details
#_autoloaded_tracked_classes ⇒ Object
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.
      66 67 68  | 
    
      # File 'lib/active_support/dependencies.rb', line 66 def _autoloaded_tracked_classes @_autoloaded_tracked_classes end  | 
  
#_eager_load_paths ⇒ Object
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.
      60 61 62  | 
    
      # File 'lib/active_support/dependencies.rb', line 60 def _eager_load_paths @_eager_load_paths end  | 
  
#autoload_once_paths ⇒ Object
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.
      53 54 55  | 
    
      # File 'lib/active_support/dependencies.rb', line 53 def autoload_once_paths @autoload_once_paths end  | 
  
#autoload_paths ⇒ Object
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.
      47 48 49  | 
    
      # File 'lib/active_support/dependencies.rb', line 47 def autoload_paths @autoload_paths end  | 
  
#autoloader ⇒ Object
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`.
      73 74 75  | 
    
      # File 'lib/active_support/dependencies.rb', line 73 def autoloader @autoloader end  | 
  
#interlock ⇒ Object
Returns the value of attribute interlock.
      9 10 11  | 
    
      # File 'lib/active_support/dependencies.rb', line 9 def interlock @interlock end  | 
  
Class Method Details
.clear ⇒ Object
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.
      80 81 82 83 84 85  | 
    
      # File 'lib/active_support/dependencies.rb', line 80 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.
      98 99 100  | 
    
      # File 'lib/active_support/dependencies.rb', line 98 def self.eager_load?(path) _eager_load_paths.member?(path) end  | 
  
.load_interlock(&block) ⇒ Object
Execute the supplied block while holding an exclusive lock, preventing any other thread from being inside a #run_interlock block at the same time.
      23 24 25 26 27 28 29 30  | 
    
      # File 'lib/active_support/dependencies.rb', line 23 def self.load_interlock(&block) ActiveSupport.deprecator.warn( "ActiveSupport::Dependencies.load_interlock is deprecated and " \ "will be removed in Rails 9.0. The loading interlock is no longer " \ "used since Rails switched to Zeitwerk for autoloading." ) yield if block end  | 
  
.run_interlock(&block) ⇒ Object
Execute the supplied block without interference from any concurrent loads.
      16 17 18  | 
    
      # File 'lib/active_support/dependencies.rb', line 16 def self.run_interlock(&block) interlock.running(&block) end  | 
  
.search_for_file(relpath) ⇒ Object
Private method used by require_dependency.
      88 89 90 91 92 93 94 95  | 
    
      # File 'lib/active_support/dependencies.rb', line 88 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) ⇒ Object
Execute the supplied block while holding an exclusive lock, preventing any other thread from being inside a #run_interlock block at the same time.
      35 36 37  | 
    
      # File 'lib/active_support/dependencies.rb', line 35 def self.unload_interlock(&block) interlock.unloading(&block) end  |