I got a few Classes that include the same module, I want to override one of the methods of the module in one place in my code.
How to do this?
I tried
module [Module_name]
def [method_to_override]
and add it to the autoload path of rails but no success
If you are using the module as a mixin, you can redefine the method in your class. The method defined at the class level will take precedence when called. The module as a mixin simply behaves as a superclass in this case.
If you are using the module as a namespace, I am not sure that there’s a way to dynamically redefine the code as you are attempting to do. Perhaps opening the namespaced module in-place and including the new code for the method will work. I haven’t tried this before.
Some reference material