Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Turn warnings on when loading a file if Dependencies.mechanism == :lo…

…ad. 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
  • Loading branch information...
commit edc7c521b8692dbbf08a6ec625d0937d6c459e65 1 parent 2b6e2bf
Jeremy Kemper jeremy authored
2  activesupport/CHANGELOG
View
@@ -1,5 +1,7 @@
*SVN*
+* Turn warnings on when loading a file if Dependencies.mechanism == :load. Common mistakes such as redefined methods will print warnings to stderr. [Jeremy Kemper]
+
* Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.]
* Added the following methods [Marcel Molina Jr., Sam Stephenson]:
15 activesupport/lib/active_support/dependencies.rb
View
@@ -33,12 +33,21 @@ def associate_with(file_name)
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
Please sign in to comment.
Something went wrong with that request. Please try again.