Permalink
Browse files

Update load once paths to prevent nested once constants from being de…

…tected and claimed by an external non-once load. References #6720

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5782 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 1e170da commit e2acd16810a597e9fa3acd6277e8371678cea34a @seckar seckar committed Dec 24, 2006
Showing with 8 additions and 2 deletions.
  1. +2 −0 activesupport/CHANGELOG
  2. +6 −2 activesupport/lib/active_support/dependencies.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Update load once paths to prevent nested once constants from being detected and claimed by an external non-once load. [Nicholas Seckar]
+
* Deprecation: silence warnings when reporting test errors. [Jeremy Kemper]
* Hash#slice(*keys) returns a new hash with only the given keys. #slice! replaces the hash with only the given keys. Works with HashWithIndifferentAccess also. [Jeremy Kemper]
@@ -130,7 +130,7 @@ def qualified_const_defined?(path)
# Given +path+, a filesystem path to a ruby file, return an array of constant
# paths which would cause Dependencies to attempt to load this file.
#
- def loadable_constants_for_path(path, bases = load_paths - load_once_paths)
+ def loadable_constants_for_path(path, bases = load_paths)
path = $1 if path =~ /\A(.*)\.rb\Z/
expanded_path = File.expand_path(path)
@@ -169,6 +169,10 @@ def autoloadable_module?(path_suffix)
nil
end
+ def load_once_path?(path)
+ load_once_paths.any? { |base| path.starts_with? base }
+ end
+
# Attempt to autoload the provided module name by searching for a directory
# matching the expect path suffix. If found, the module is created and assigned
# to +into+'s constants with the name +const_name+. Provided that the directory
@@ -200,7 +204,7 @@ def load_file(path, const_paths = loadable_constants_for_path(path))
result = load_without_new_constant_marking path
end
- autoloaded_constants.concat newly_defined_paths
+ autoloaded_constants.concat newly_defined_paths unless load_once_path?(path)
autoloaded_constants.uniq!
log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty?
return result

0 comments on commit e2acd16

Please sign in to comment.