1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

update AS/deprecation docs [ci skip]

This commit is contained in:
Francesco Rodriguez 2012-09-14 22:28:56 -05:00
parent f210a369d1
commit 8673c2eefb
2 changed files with 9 additions and 9 deletions

View file

@ -6,13 +6,13 @@ module ActiveSupport
# Whether to print a backtrace along with the warning.
attr_accessor :debug
# Returns the current behavior or if one isn't set, defaults to +:stderr+
# Returns the current behavior or if one isn't set, defaults to +:stderr+.
def behavior
@behavior ||= [DEFAULT_BEHAVIORS[:stderr]]
end
# Sets the behavior to the specified value. Can be a single value, array, or
# an object that responds to +call+.
# Sets the behavior to the specified value. Can be a single value, array,
# or an object that responds to +call+.
#
# Available behaviors:
#
@ -22,13 +22,13 @@ module ActiveSupport
# [+silence+] Do nothing.
#
# Setting behaviors only affects deprecations that happen after boot time.
# Deprecation warnings raised by gems are not affected by this setting because
# they happen before Rails boots up.
# Deprecation warnings raised by gems are not affected by this setting
# because they happen before Rails boots up.
#
# ActiveSupport::Deprecation.behavior = :stderr
# ActiveSupport::Deprecation.behavior = [:stderr, :log]
# ActiveSupport::Deprecation.behavior = MyCustomHandler
# ActiveSupport::Deprecation.behavior = proc { |message, callstack|
# ActiveSupport::Deprecation.behavior = proc { |message, callstack|
# # custom stuff
# }
def behavior=(behavior)

View file

@ -6,7 +6,7 @@ module ActiveSupport
# Outputs a deprecation warning to the output configured by
# <tt>ActiveSupport::Deprecation.behavior</tt>.
#
# ActiveSupport::Deprecation.warn("something broke!")
# ActiveSupport::Deprecation.warn('something broke!')
# # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)"
def warn(message = nil, callstack = caller)
return if silenced
@ -17,11 +17,11 @@ module ActiveSupport
# Silence deprecation warnings within the block.
#
# ActiveSupport::Deprecation.warn("something broke!")
# ActiveSupport::Deprecation.warn('something broke!')
# # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)"
#
# ActiveSupport::Deprecation.silence do
# ActiveSupport::Deprecation.warn("something broke!")
# ActiveSupport::Deprecation.warn('something broke!')
# end
# # => nil
def silence