aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-24 20:26:01 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-24 20:26:01 +0000
commite7219e9e2a17fad73a2eaca0ffc7f118894934d8 (patch)
tree816a3489c849d1778e2d80a3147768137c051c31 /activesupport/lib
parent14d50e9da3bb67a881afc2aed2662b5c10005eec (diff)
downloadrails-e7219e9e2a17fad73a2eaca0ffc7f118894934d8.tar.gz
rails-e7219e9e2a17fad73a2eaca0ffc7f118894934d8.tar.bz2
rails-e7219e9e2a17fad73a2eaca0ffc7f118894934d8.zip
Introduce Dependencies.warnings_on_first_load setting. If true, enables warnings on first load of a require_dependency. Otherwise, loads without warnings. Disabled (set to false) by default.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3190 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/dependencies.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index bce5855c4a..64732db136 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -6,6 +6,10 @@ require File.dirname(__FILE__) + '/core_ext/kernel'
module Dependencies #:nodoc:
extend self
+ # Should we turn on Ruby warnings on the first load of dependent files?
+ mattr_accessor :warnings_on_first_load
+ self.warnings_on_first_load = false
+
# All files ever loaded.
mattr_accessor :history
self.history = Set.new
@@ -50,8 +54,9 @@ module Dependencies #:nodoc:
loaded << file_name
begin
- # Enable warnings iff this file has not been loaded before.
- if history.include?(file_name)
+ # Enable warnings iff this file has not been loaded before and
+ # warnings_on_first_load is set.
+ if !warnings_on_first_load or history.include?(file_name)
load load_file_name
else
enable_warnings { load load_file_name }