Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5782

Show
Ignore:
Timestamp:
12/24/06 14:53:35 (2 years ago)
Author:
ulysses
Message:

Update load once paths to prevent nested once constants from being detected and claimed by an external non-once load. References #6720

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r5728 r5782  
    11*SVN* 
     2 
     3* Update load once paths to prevent nested once constants from being detected and claimed by an external non-once load. [Nicholas Seckar] 
    24 
    35* Deprecation: silence warnings when reporting test errors.  [Jeremy Kemper] 
  • trunk/activesupport/lib/active_support/dependencies.rb

    r5710 r5782  
    131131  # paths which would cause Dependencies to attempt to load this file. 
    132132  #  
    133   def loadable_constants_for_path(path, bases = load_paths - load_once_paths
     133  def loadable_constants_for_path(path, bases = load_paths
    134134    path = $1 if path =~ /\A(.*)\.rb\Z/ 
    135135    expanded_path = File.expand_path(path) 
     
    170170  end 
    171171   
     172  def load_once_path?(path) 
     173    load_once_paths.any? { |base| path.starts_with? base } 
     174  end 
     175   
    172176  # Attempt to autoload the provided module name by searching for a directory 
    173177  # matching the expect path suffix. If found, the module is created and assigned 
     
    201205    end 
    202206     
    203     autoloaded_constants.concat newly_defined_paths 
     207    autoloaded_constants.concat newly_defined_paths unless load_once_path?(path) 
    204208    autoloaded_constants.uniq! 
    205209    log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty?