instance method deprecate_methods

Ruby on Rails 4.1.16

Since v4.0.13

Available in: v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

deprecate_methods(target_module, *method_names)

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)."

Parameters

target_module req
method_names rest
Source
# File activesupport/lib/active_support/deprecation/method_wrappers.rb, line 28
      def deprecate_methods(target_module, *method_names)
        options = method_names.extract_options!
        deprecator = options.delete(:deprecator) || ActiveSupport::Deprecation.instance
        method_names += options.keys

        method_names.each do |method_name|
          target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
            target_module.send(:define_method, "#{target}_with_deprecation#{punctuation}") do |*args, &block|
              deprecator.deprecation_warning(method_name, options[method_name])
              send(:"#{target}_without_deprecation#{punctuation}", *args, &block)
            end
          end
        end
      end

Defined in activesupport/lib/active_support/deprecation/method_wrappers.rb line 28 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Deprecation::MethodWrapper

Type at least 2 characters to search.

↑↓ navigate · open · esc close