Module: ActiveAdmin::Deprecation

Defined in:
lib/active_admin/deprecation.rb

Class Method Summary collapse

Class Method Details

.deprecate(klass, method, message) ⇒ Object

Deprecate a method.

Example:

class MyClass
  def my_method
    # ...
  end
  ActiveAdmin::Deprecation.deprecate self, :my_method,
    "MyClass#my_method is being removed in the next release"
end

Parameters:

  • klass (Module)

    the Class or Module to deprecate the method on

  • method (Symbol)

    the method to deprecate

  • message (String)

    the message to display to the end user



25
26
27
28
29
30
31
32
33
# File 'lib/active_admin/deprecation.rb', line 25

def deprecate(klass, method, message)
  klass.class_eval "    alias_method :deprecated_\#{method}, :\#{method}\n    def \#{method}(*args)\n      ActiveAdmin::Deprecation.warn('\#{message}', caller)\n      send(:deprecated_\#{method}, *args)\n    end\n  EOC\nend\n", __FILE__, __LINE__ + 1

.warn(message, callstack = caller) ⇒ Object



5
6
7
# File 'lib/active_admin/deprecation.rb', line 5

def warn(message, callstack = caller)
  ActiveSupport::Deprecation.warn "Active Admin: #{message}", callstack
end