Permalink
Browse files

add example to AS::Deprecation#deprecate_methods [ci skip]

  • Loading branch information...
1 parent e925d56 commit 55f8b0d09e3963f8d662c79952a1f9c3a0a4e1f3 Francesco Rodriguez committed Jun 18, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 activesupport/lib/active_support/deprecation/method_wrappers.rb
@@ -4,6 +4,26 @@
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

0 comments on commit 55f8b0d

Please sign in to comment.