diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-08-16 17:50:52 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-08-16 17:50:52 +0000 |
commit | 593f04e6a939caeed276b855fc7fa35655ba1204 (patch) | |
tree | 32560660627730aa894d8164aabe3beac54c5b14 /activesupport/lib | |
parent | ae74e8e9feba99b84f5e431239dc6a2039ad5793 (diff) | |
download | rails-593f04e6a939caeed276b855fc7fa35655ba1204.tar.gz rails-593f04e6a939caeed276b855fc7fa35655ba1204.tar.bz2 rails-593f04e6a939caeed276b855fc7fa35655ba1204.zip |
Stop using defined? in Dependencies.qualified_const_defined? since defined? may invoke const_missing.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4774 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 12 |
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 |