Permalink
Browse files

add example to AS::Deprecation#silence [ci skip]

  • Loading branch information...
1 parent a7a4e91 commit 508538066c54b88bd2cca243ceaf5b65c0bee4ec Francesco Rodriguez committed Jun 17, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 activesupport/lib/active_support/deprecation/reporting.rb
View
11 activesupport/lib/active_support/deprecation/reporting.rb
@@ -3,7 +3,8 @@ module Deprecation
class << self
attr_accessor :silenced
- # Outputs a deprecation warning to the output configured by <tt>ActiveSupport::Deprecation.behavior</tt>
+ # Outputs a deprecation warning to the output configured by
+ # <tt>ActiveSupport::Deprecation.behavior</tt>.
#
# ActiveSupport::Deprecation.warn("something broke!")
# # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)"
@@ -15,6 +16,14 @@ def warn(message = nil, callstack = caller)
end
# Silence deprecation warnings within the block.
+ #
+ # ActiveSupport::Deprecation.warn("something broke!")
+ # # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)"
+ #
+ # Activesupport::Deprecation.silence do
+ # ActiveSupport::Deprecation.warn("something broke!")
+ # end
+ # # => nil
def silence
old_silenced, @silenced = @silenced, true
yield

0 comments on commit 5085380

Please sign in to comment.