diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-03-27 05:13:46 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-03-27 05:13:46 +0000 |
commit | 9efca53908c09b7f188183aec6c0a4a2df347316 (patch) | |
tree | bd1eacf10bdcaef1112bf0c36d3a3743fb092733 /activesupport/lib/active_support/dependencies.rb | |
parent | 24403498ba8582d29f55aab16ffd5920dec1c669 (diff) | |
download | rails-9efca53908c09b7f188183aec6c0a4a2df347316.tar.gz rails-9efca53908c09b7f188183aec6c0a4a2df347316.tar.bz2 rails-9efca53908c09b7f188183aec6c0a4a2df347316.zip |
Dependencies cleanup. Fixes #4221.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4060 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/dependencies.rb')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index b82c7e56f3..ffddda6f03 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -78,23 +78,6 @@ class Module #:nodoc: # Rename the original handler so we can chain it to the new one alias :rails_original_const_missing :const_missing - def parent - parent_name = name.split('::')[0..-2] * '::' - parent_name.empty? ? Object : parent_name.constantize - end - - def as_load_path - if self == Object || self == Kernel - '' - elsif is_a? Class - parent == self ? '' : parent.as_load_path - else - name.split('::').collect do |word| - word.underscore - end * '/' - end - end - # Use const_missing to autoload associations so we don't have to # require_association when using single-table inheritance. def const_missing(class_id) @@ -116,7 +99,11 @@ class Module #:nodoc: return mod end - if parent && parent != self + # Attempt to access the name from the parent, unless we don't have a valid + # parent, or the constant is already defined in the parent. If the latter + # is the case, then we are being queried via self::class_id, and we should + # avoid returning the constant from the parent if possible. + if parent && parent != self && ! parents.any? { |p| p.const_defined?(class_id) } suppress(NameError) do return parent.send(:const_missing, class_id) end |