aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-10 15:01:35 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-10 15:01:35 +0000
commit87bed3af479c4df720304fea21a9a14d34eb4544 (patch)
tree592d829b45ee65a48f703b92eac53777ba5f673a /activesupport/lib
parenta04fc268b769f9e38ebdec0674fc3c6ec57fef1c (diff)
downloadrails-87bed3af479c4df720304fea21a9a14d34eb4544.tar.gz
rails-87bed3af479c4df720304fea21a9a14d34eb4544.tar.bz2
rails-87bed3af479c4df720304fea21a9a14d34eb4544.zip
Fixed that in some circumstances controllers outside of modules may have hidden ones inside modules. For example, admin/content might have been hidden by /content. #1075 [Nicholas Seckar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1125 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/dependencies.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 91f1f54f5a..dd71949399 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -55,7 +55,7 @@ module Dependencies
def self.root(*load_paths)
RootLoadingModule.new(*load_paths)
end
-
+
def initialize(root, path=[])
@path = path.clone.freeze
@root = root
@@ -81,9 +81,11 @@ module Dependencies
new_module = LoadingModule.new(self.root, self.path + [name])
self.const_set name, new_module
if self.root?
- raise NameError, "Cannot load controller module named #{name}: An object of type #{Object.const_get(name).class.to_s} already exists." \
- if Object.const_defined?(name)
- Object.const_set(name, new_module)
+ if Object.const_defined?(name)
+ msg = "Cannot load module #{name}: Object::#{name} is set to #{Object.const_get(name).inspect}"
+ raise NameError, msg
+ end
+ Object.const_set(name, new_module)
end
break
elsif File.file?(fs_path)
@@ -94,7 +96,7 @@ module Dependencies
break
end
end
-
+
return self.const_defined?(name)
end
@@ -124,7 +126,7 @@ module Dependencies
# Erase all items in this module
def clear!
constants.each do |name|
- Object.send(:remove_const, name) if Object.const_defined?(name)
+ Object.send(:remove_const, name) if Object.const_defined?(name) && Object.const_get(name).object_id == self.const_get(name).object_id
self.send(:remove_const, name)
end
end