Skip to content

Commit

Permalink
add example to AS::Deprecation#deprecate_methods [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Rodriguez committed Jun 18, 2012
1 parent e925d56 commit 55f8b0d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions activesupport/lib/active_support/deprecation/method_wrappers.rb
Expand Up @@ -4,6 +4,26 @@
module ActiveSupport module ActiveSupport
module Deprecation module Deprecation
# Declare that a method has been deprecated. # 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) def self.deprecate_methods(target_module, *method_names)
options = method_names.extract_options! options = method_names.extract_options!
method_names += options.keys method_names += options.keys
Expand Down

0 comments on commit 55f8b0d

Please sign in to comment.