Module: ActiveAdmin::Deprecation

Defined in:
lib/active_admin/deprecation.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) deprecate(klass, method, message)

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


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

def deprecate(klass, method, message)
  klass.send :define_method, "deprecated_#{method}", klass.instance_method(method)

  klass.send :define_method, method do |*args|
    ActiveAdmin::Deprecation.warn "#{message}", caller
    send "deprecated_#{method}", *args
  end
end

+ (Object) warn(message, callstack = caller)



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

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