Skip to content

Commit

Permalink
add example to AS::Deprecation#silence [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Rodriguez committed Jun 17, 2012
1 parent a7a4e91 commit 5085380
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion activesupport/lib/active_support/deprecation/reporting.rb
Expand Up @@ -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)"
Expand All @@ -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
Expand Down

0 comments on commit 5085380

Please sign in to comment.