Permalink
Browse files

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
  • Loading branch information...
jamis committed Oct 3, 2005
1 parent f13534e commit 33f78d822759aed125b2fb8fe0a9b3a5704d3239
Showing with 10 additions and 1 deletion.
  1. +2 −0 activesupport/CHANGELOG
  2. +8 −1 activesupport/lib/active_support/dependencies.rb
View
@@ -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]
@@ -178,6 +178,9 @@ def const_name_to_module_name(name)
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 @@ def const_missing(class_id)
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

0 comments on commit 33f78d8

Please sign in to comment.