aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-19 19:17:08 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-19 19:17:08 +0000
commit4a7225a1bdf693af9e0e22bec5b61061179fdb1f (patch)
treec971fea826a15aa6d35291026fe9fcad6866cbae /activesupport
parent71b6f76543686a9ffdc3d6f9045de195ce7d7272 (diff)
downloadrails-4a7225a1bdf693af9e0e22bec5b61061179fdb1f.tar.gz
rails-4a7225a1bdf693af9e0e22bec5b61061179fdb1f.tar.bz2
rails-4a7225a1bdf693af9e0e22bec5b61061179fdb1f.zip
Fixed Dependencies so all modules are able to load missing constants #1173 [Nicholas Seckar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1331 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/dependencies.rb30
2 files changed, 17 insertions, 15 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 0727790c47..ac3e9eb7e5 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed Dependencies so all modules are able to load missing constants #1173 [Nicholas Seckar]
+
* Fixed the Inflector to underscore strings containing numbers, so Area51Controller becomes area51_controller #1176 [Nicholas Seckar]
* Fixed that HashWithIndifferentAccess stringified all keys including symbols, ints, objects, and arrays #1162 [Nicholas Seckar]
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index dd71949399..dd210a8ebd 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -167,24 +167,24 @@ Object.send(:define_method, :require_or_load) { |file_name| Dependencies.req
Object.send(:define_method, :require_dependency) { |file_name| Dependencies.depend_on(file_name) } unless Object.respond_to?(:require_dependency)
Object.send(:define_method, :require_association) { |file_name| Dependencies.associate_with(file_name) } unless Object.respond_to?(:require_association)
-class Object #:nodoc:
- class << self
- # Use const_missing to autoload associations so we don't have to
- # require_association when using single-table inheritance.
- def const_missing(class_id)
- if Object.const_defined?(:Controllers) and Object::Controllers.const_available?(class_id)
- return Object::Controllers.const_get(class_id)
- end
-
- begin
- 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)
- end
+class Module #:nodoc:
+ # Use const_missing to autoload associations so we don't have to
+ # require_association when using single-table inheritance.
+ def const_missing(class_id)
+ if Object.const_defined?(:Controllers) and Object::Controllers.const_available?(class_id)
+ return Object::Controllers.const_get(class_id)
+ end
+
+ begin
+ 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)
end
end
+end
+class Object #:nodoc:
def load(file, *extras)
begin super(file, *extras)
rescue Object => exception