module Module::DeprecatePublic
Public Instance Methods
method_missing(meth, *args, &block)
click to toggle source
Handle calls to methods where deprecate_public
has been called for the method, printing the warning and then using send
to invoke the method.
Calls superclass method
# File lib/deprecate_public.rb 6 def method_missing(meth, *args, &block) 7 check_meth = "_deprecated_public_message_#{meth}" 8 if respond_to?(meth, true) && respond_to?(check_meth, true) && (msg = send(check_meth)) 9 if RUBY_VERSION >= '2.5' 10 Kernel.warn(msg, :uplevel => 1) 11 elsif RUBY_VERSION >= '2.0' 12 Kernel.warn("#{caller(1,1)[0].sub(/in `.*'\z/, '')} warning: #{msg}") 13 else 14 Kernel.warn("#{caller(1)[0].sub(/in `.*'\z/, '')} warning: #{msg}") 15 end 16 17 send(meth, *args, &block) 18 else 19 super 20 end 21 end