aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 18:00:15 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 18:00:15 +0000
commitee662e9768f3682389daaa54d38c3e46cdcd4408 (patch)
treee98164fe1659358726b4ff30a6fab9ecc3abab8e /activesupport/lib
parentc37e8d365b9470a593668476fc9be0af6da2e812 (diff)
downloadrails-ee662e9768f3682389daaa54d38c3e46cdcd4408.tar.gz
rails-ee662e9768f3682389daaa54d38c3e46cdcd4408.tar.bz2
rails-ee662e9768f3682389daaa54d38c3e46cdcd4408.zip
New approach to reloading that uses remove_const on ARs and AOs as well as ACs
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@507 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/dependencies.rb18
1 files changed, 4 insertions, 14 deletions
diff --git a/activesupport/lib/dependencies.rb b/activesupport/lib/dependencies.rb
index 90b3dea5d5..3ceec71873 100644
--- a/activesupport/lib/dependencies.rb
+++ b/activesupport/lib/dependencies.rb
@@ -18,8 +18,8 @@ module Dependencies
loaded << file_name
begin
require_or_load(file_name)
- rescue LoadError
- raise unless swallow_load_errors
+ rescue Object => e
+ raise ScriptError, "#{e.message}" unless e.is_a?(LoadError) && swallow_load_errors
end
end
end
@@ -32,18 +32,8 @@ module Dependencies
self.loaded = [ ]
end
- def reload
- loaded.each do |file_name|
- begin
- silence_warnings { load("#{file_name}.rb") }
- rescue LoadError
- # We don't care if the file was removed now
- end
- end
- end
-
def require_or_load(file_name)
- mechanism == :load ? silence_warnings { load("#{file_name}.rb") } : require(file_name)
+ load? ? load("#{file_name}.rb") : require(file_name)
end
end
@@ -57,7 +47,7 @@ class Object #:nodoc:
# require_association when using single-table inheritance.
def const_missing(class_id)
begin
- require_dependency(Inflector.underscore(Inflector.demodulize(class_id.to_s)))
+ require_or_load(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
raise NameError, "uninitialized constant #{class_id}"