I am trying to implement the inherited method for ActionController::Base class. My purpose is to call methods on classes that inherit from ActionController::Base like ApplicationController to make them include certain modules. At the momement my Code looks like this:
module MyModule
def inherited(child)
end
def my_test_method()
end
end
ActionController::Base.send(:extend, MyModule)
ActionController::Base.methods.include? 'my_test_method'
=> true
ActionController::Base.methods.include? 'inherited'
=> false
The code is called out of an init file of a plugin.
inherited is a class method of Class. It can be overwritten directly to add behavior when a child class is defined. I don't see how you can do this by extending a module, but this should achieve the same result:
and you will get the output: