From 55f8b0d09e3963f8d662c79952a1f9c3a0a4e1f3 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 18 Jun 2012 15:00:58 -0500 Subject: add example to AS::Deprecation#deprecate_methods [ci skip] --- .../active_support/deprecation/method_wrappers.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 -- cgit v1.2.3