alias_method
makes a copy of a method. This works fine until the same method is overridden using prepend
. If the prepend
is executed after alias_method
, you'll either see an infinite loop, or loose the prepended functionality.
Solution
Your options are:
- Ensure
prepend
happens beforealias_method
- If you can control the
alias_method
invocation: rewrite to the modern & betterprepend
- If you can only control the
prepend
invocation: rewrite to the legacyalias_method
Posted by Dominik Schöler to makandra dev (2023-07-31 08:13)