aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/dependencies.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 6241a822a4..b8a8a9b630 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -96,7 +96,17 @@ module Dependencies #:nodoc:
def qualified_const_defined?(path)
raise NameError, "#{path.inspect} is not a valid constant name!" unless
/^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path
- Object.module_eval("defined?(#{path})", __FILE__, __LINE__)
+
+ names = path.split('::')
+ names.shift if names.first.empty?
+
+ # We can't use defined? because it will invoke const_missing for the parent
+ # of the name we are checking.
+ names.inject(Object) do |mod, name|
+ return false unless mod.const_defined? name
+ mod.const_get name
+ end
+ return true
end
# Given +path+ return an array of constant paths which would cause Dependencies