aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/deprecation.rb16
-rw-r--r--activesupport/lib/active_support/reloadable.rb7
-rw-r--r--activesupport/test/deprecation_test.rb6
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/dispatcher.rb4
6 files changed, 32 insertions, 5 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 715315deb2..48bcd264c5 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add Deprecation.silence so that Reloadable does not scold itself. [Nicholas Seckar]
+
* Add debugging logging to Dependencies. Currently can be enabled with Dependencies.log_activity = true; adding to Initializer and documenting is forthcoming. [Nicholas Seckar]
* Replace Reloadable with improvements to the Dependencies mechanism. [Nicholas Seckar]
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index d6c9317f06..99c27ee9d1 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -9,13 +9,27 @@ module ActiveSupport
class << self
def warn(message = nil, callstack = caller)
- behavior.call(deprecation_message(callstack, message)) if behavior
+ behavior.call(deprecation_message(callstack, message)) if behavior && ! silenced?
end
def default_behavior
DEFAULT_BEHAVIORS[RAILS_ENV.to_s] if defined?(RAILS_ENV)
end
+ # Have deprecations been silenced?
+ def silenced?
+ @silenced
+ end
+
+ # Silence deprecations for the duration of the provided block. For internal
+ # use only.
+ def silence
+ old_silenced, @silenced = @silenced, true # We could have done behavior = nil...
+ yield
+ ensure
+ @silenced = old_silenced
+ end
+
private
def deprecation_message(callstack, message = nil)
file, line, method = extract_callstack(callstack)
diff --git a/activesupport/lib/active_support/reloadable.rb b/activesupport/lib/active_support/reloadable.rb
index 3f57723e15..baa8741b30 100644
--- a/activesupport/lib/active_support/reloadable.rb
+++ b/activesupport/lib/active_support/reloadable.rb
@@ -25,10 +25,11 @@ module Reloadable
end
def reloadable_classes
- included_in_classes.select { |klass| klass.reloadable? }
+ ActiveSupport::Deprecation.silence do
+ included_in_classes.select { |klass| klass.reloadable? }
+ end
end
- # Commented out so dispatcher doesn't warn. Should we just disable Reloadable?
- # deprecate :reloadable_classes
+ deprecate :reloadable_classes
end
# Captures the common pattern where a base class should not be reloaded,
diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb
index 1a054335d7..7c5cb5783c 100644
--- a/activesupport/test/deprecation_test.rb
+++ b/activesupport/test/deprecation_test.rb
@@ -78,4 +78,10 @@ class DeprecationTest < Test::Unit::TestCase
end
end
+ def test_silence
+ ActiveSupport::Deprecation.silence do
+ assert_not_deprecated { @dtc.partially }
+ end
+ end
+
end
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 8bf2fafd6e..294e961f28 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar]
+
* Rearrange application resetting and preparation, fix bug with leaking subclasses hash in ActiveRecord::Base [Rick Olson]
ActiveRecord::Base.reset_subclasses is called before Dependencies are cleared and classes removed.
diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb
index 17e5ae74f7..78f2d9fe43 100644
--- a/railties/lib/dispatcher.rb
+++ b/railties/lib/dispatcher.rb
@@ -56,7 +56,9 @@ class Dispatcher
def reset_application!
ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
Dependencies.clear
- Class.remove_class(*Reloadable.reloadable_classes)
+ ActiveSupport::Deprecation.silence do # TODO: Remove after 1.2
+ Class.remove_class(*Reloadable.reloadable_classes)
+ end
end