Chain the const_missing hook to any previously existing hook so rails can play nicely with rake

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2440 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck
2005-10-03 15:28:08 +00:00
parent f13534e65f
commit 33f78d8227
2 changed files with 10 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
*SVN*
* Chain the const_missing hook to any previously existing hook so rails can play nicely with rake
* Clean logger is compatible with both 1.8.2 and 1.8.3 Logger. #2263 [Michael Schuerig <michael@schuerig.de>]
* Added native, faster implementations of .blank? for the core types #2286 [skae]

View File

@@ -178,6 +178,9 @@ Object.send(:define_method, :require_dependency) { |file_name| Dependencies.dep
Object.send(:define_method, :require_association) { |file_name| Dependencies.associate_with(file_name) } unless Object.respond_to?(:require_association)
class Module #:nodoc:
# Rename the original handler so we can chain it to the new one
alias :rails_original_const_missing :const_missing
# Use const_missing to autoload associations so we don't have to
# require_association when using single-table inheritance.
def const_missing(class_id)
@@ -189,7 +192,11 @@ class Module #:nodoc:
require_dependency(class_id.to_s.demodulize.underscore)
if Object.const_defined?(class_id) then return Object.const_get(class_id) else raise LoadError end
rescue LoadError => e
raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e)
begin
rails_original_const_missing(class_id)
rescue Exception
raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e)
end
end
end
end