How to abandon a static method in Rails?

According to the Ruby on Rails API docs, you can opt out of methods using the # deprecate method. Everything is good.

My question is: can static methods be discounted - if so, how?

For regular methods, you can simply do something like this:

deprecate :my_method def my_method # ... end 

This bot gives me a headache (and it doesnโ€™t work):

 deprecate :"self.my_method" def self.my_method # ... end 

Ps: I know that I can trigger a warning from a method as follows:

 def self.my_method ActiveSupport::Deprecation.warn "the warning..." # ... end 
+4
source share
1 answer

In the metaclass, you should call derecate:

 class Test1 def self.hello puts "Test1" end singleton_class.deprecate :hello # or class << self ; deprecate :hello ; end end 
+3
source

All Articles