aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/deprecation
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-06-22 22:15:27 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-06-22 22:15:27 +0530
commit35ee8fa3d8b3ad49179f86af2bec2e53af335ac9 (patch)
tree5929e772a461c683c54c1fd66b303516e5d0df33 /activesupport/lib/active_support/deprecation
parentfb8cf55868d555b7f06215db5976c8aaf083d30b (diff)
parent6285675db1cf983ba6c15442aedb457c8041f5ee (diff)
downloadrails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.gz
rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.tar.bz2
rails-35ee8fa3d8b3ad49179f86af2bec2e53af335ac9.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activesupport/lib/active_support/deprecation')
-rw-r--r--activesupport/lib/active_support/deprecation/method_wrappers.rb20
-rw-r--r--activesupport/lib/active_support/deprecation/reporting.rb11
2 files changed, 30 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/deprecation/method_wrappers.rb b/activesupport/lib/active_support/deprecation/method_wrappers.rb
index c5de5e6a95..257b70e34a 100644
--- a/activesupport/lib/active_support/deprecation/method_wrappers.rb
+++ b/activesupport/lib/active_support/deprecation/method_wrappers.rb
@@ -4,6 +4,26 @@ require 'active_support/core_ext/array/extract_options'
module ActiveSupport
module Deprecation
# Declare that a method has been deprecated.
+ #
+ # module Fred
+ # extend self
+ #
+ # def foo; end
+ # def bar; end
+ # def baz; end
+ # end
+ #
+ # ActiveSupport::Deprecation.deprecate_methods(Fred, :foo, bar: :qux, baz: 'use Bar#baz instead')
+ # # => [:foo, :bar, :baz]
+ #
+ # Fred.foo
+ # # => "DEPRECATION WARNING: foo is deprecated and will be removed from Rails 4.1."
+ #
+ # Fred.bar
+ # # => "DEPRECATION WARNING: bar is deprecated and will be removed from Rails 4.1 (use qux instead)."
+ #
+ # Fred.baz
+ # # => "DEPRECATION WARNING: baz is deprecated and will be removed from Rails 4.1 (use Bar#baz instead)."
def self.deprecate_methods(target_module, *method_names)
options = method_names.extract_options!
method_names += options.keys
diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb
index 5d7e241d1a..a1e9618084 100644
--- a/activesupport/lib/active_support/deprecation/reporting.rb
+++ b/activesupport/lib/active_support/deprecation/reporting.rb
@@ -3,7 +3,8 @@ module ActiveSupport
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 @@ module ActiveSupport
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