diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-21 07:06:33 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-21 07:06:33 +0000 |
commit | edc7c521b8692dbbf08a6ec625d0937d6c459e65 (patch) | |
tree | 130010aa245606386c0b55c89266775b92339344 /activesupport/lib/active_support | |
parent | 2b6e2bfed79e30d6d72fcac6a068e9fcbbf4f610 (diff) | |
download | rails-edc7c521b8692dbbf08a6ec625d0937d6c459e65.tar.gz rails-edc7c521b8692dbbf08a6ec625d0937d6c459e65.tar.bz2 rails-edc7c521b8692dbbf08a6ec625d0937d6c459e65.zip |
Turn warnings on when loading a file if Dependencies.mechanism == :load. Common mistakes such as redefined methods will print warnings to stderr. References #752. References #1792.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3124 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 9681af6dff..30911453bc 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -33,12 +33,21 @@ module Dependencies #:nodoc: def clear self.loaded = [ ] end - + def require_or_load(file_name) file_name = "#{file_name}.rb" unless ! load? || file_name[-3..-1] == '.rb' - load? ? load(file_name) : require(file_name) + if load? + begin + original_verbosity, $VERBOSE = $VERBOSE, true + load file_name + ensure + $VERBOSE = original_verbosity + end + else + require file_name + end end - + def remove_subclasses_for(*classes) Object.remove_subclasses_of(*classes) end |