Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/deprecate_public.rb

Defined Under Namespace

Modules: DeprecatePublic

Instance Method Summary collapse

Instance Method Details

#deprecate_public(meth, msg = nil) ⇒ Object

Allow but deprecate public method calls to meth, if meth is protected or private. meth can be an array of method name strings or symbols to handle multiple methods at once. If msg is specified, it can be used to customize the warning printed.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/deprecate_public.rb', line 26

def deprecate_public(meth, msg=nil)
  include DeprecatePublic

  Array(meth).each do |m|
    message = (msg || "calling #{name}##{m} using deprecated public interface").dup.freeze
    message_meth = :"_deprecated_public_message_#{m}"
    define_method(message_meth){message}
    private message_meth
  end

  nil
end