diff options
author | José Valim <jose.valim@gmail.com> | 2010-07-01 10:26:45 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-01 10:26:45 +0200 |
commit | e596a8e14cfb1f2ca19cd20ae7e40047d4819b3e (patch) | |
tree | e5b631cbca801afa53d8805ea2752b35d727df13 /activesupport/lib/active_support/deprecation | |
parent | f3fedd7f84c25d1d99a70af1e21e20abb48f100f (diff) | |
download | rails-e596a8e14cfb1f2ca19cd20ae7e40047d4819b3e.tar.gz rails-e596a8e14cfb1f2ca19cd20ae7e40047d4819b3e.tar.bz2 rails-e596a8e14cfb1f2ca19cd20ae7e40047d4819b3e.zip |
Add the possibility to have several behaviors in AS::Deprecation.
Diffstat (limited to 'activesupport/lib/active_support/deprecation')
-rw-r--r-- | activesupport/lib/active_support/deprecation/behaviors.rb | 3 | ||||
-rw-r--r-- | activesupport/lib/active_support/deprecation/reporting.rb | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/deprecation/behaviors.rb b/activesupport/lib/active_support/deprecation/behaviors.rb index feb1508586..f0842f201d 100644 --- a/activesupport/lib/active_support/deprecation/behaviors.rb +++ b/activesupport/lib/active_support/deprecation/behaviors.rb @@ -1,4 +1,5 @@ require "active_support/notifications" +require "active_support/core_ext/array/wrap" module ActiveSupport module Deprecation @@ -11,7 +12,7 @@ module ActiveSupport end def behavior=(behavior) - @behavior = DEFAULT_BEHAVIORS[behavior] || behavior + @behavior = Array.wrap(behavior).map { |b| DEFAULT_BEHAVIORS[b] || b } end end diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb index 03c445ffbf..49d58cd3a1 100644 --- a/activesupport/lib/active_support/deprecation/reporting.rb +++ b/activesupport/lib/active_support/deprecation/reporting.rb @@ -4,8 +4,9 @@ module ActiveSupport attr_accessor :silenced def warn(message = nil, callstack = caller) - if behavior && !silenced - behavior.call(deprecation_message(callstack, message), callstack) + return if silenced + deprecation_message(callstack, message).tap do |m| + behavior.each { |b| b.call(m, callstack) } end end |