aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-08-14 18:15:44 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-08-14 18:15:44 +0000
commit30fa7053be89de6a4615788862e052be925342c2 (patch)
tree1e53ff64597c9c501497d6cc5ee5c257ce51105a /activesupport/lib
parent2ac4839050f28d78f49d073f0d24dc29dd3e0244 (diff)
downloadrails-30fa7053be89de6a4615788862e052be925342c2.tar.gz
rails-30fa7053be89de6a4615788862e052be925342c2.tar.bz2
rails-30fa7053be89de6a4615788862e052be925342c2.zip
Add silencing to deprecations; avoid self-scolding.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4760 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/deprecation.rb16
-rw-r--r--activesupport/lib/active_support/reloadable.rb7
2 files changed, 19 insertions, 4 deletions
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,