aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-12-24 14:53:35 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-12-24 14:53:35 +0000
commite2acd16810a597e9fa3acd6277e8371678cea34a (patch)
tree3967bb3d632fd589bbc4896824ffbb9eb8d8d03a /activesupport/lib/active_support
parent1e170da30db4be2ecfb83a5690b260a4ecfc19b3 (diff)
downloadrails-e2acd16810a597e9fa3acd6277e8371678cea34a.tar.gz
rails-e2acd16810a597e9fa3acd6277e8371678cea34a.tar.bz2
rails-e2acd16810a597e9fa3acd6277e8371678cea34a.zip
Update load once paths to prevent nested once constants from being detected 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
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/dependencies.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index b169393bf7..aa5b8d20da 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -130,7 +130,7 @@ module Dependencies #:nodoc:
# 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 @@ module Dependencies #:nodoc:
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 @@ module Dependencies #:nodoc:
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