aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-08-16 20:54:25 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-08-16 20:54:25 +0000
commit2b37d59976268013b7e518e5af244947f688d315 (patch)
tree2ad49e2e529da6c805d3d623e873e442e6335ac4 /activesupport/lib/active_support
parent38f598ec0b28919ff0d996bcb9ed923fbd99316f (diff)
downloadrails-2b37d59976268013b7e518e5af244947f688d315.tar.gz
rails-2b37d59976268013b7e518e5af244947f688d315.tar.bz2
rails-2b37d59976268013b7e518e5af244947f688d315.zip
Fix const_missing to behave responsibly when called within anonymous modules
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4779 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/dependencies.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index c0ee5ddfa8..5f3c35839b 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -65,7 +65,7 @@ module Dependencies #:nodoc:
# Record that we've seen this file *before* loading it to avoid an
# infinite loop with mutual dependencies.
loaded << expanded
-
+
if load?
log "loading #{file_name}"
begin
@@ -179,6 +179,11 @@ module Dependencies #:nodoc:
def load_missing_constant(from_mod, const_name)
log_call from_mod, const_name
+ # If we have an anonymous module, all we can do is attempt to load from Object.
+ from_mod = Object if from_mod.name.empty?
+
+ raise ArgumentError, "Expected #{from_mod} is not missing constant #{const_name}!" if from_mod.const_defined?(const_name)
+
qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore
name_error = NameError.new("uninitialized constant #{qualified_name}")