Read more

Ruby: alias_method conflicting with prepend

Dominik Schöler
July 31, 2023Software engineer at makandra GmbH

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

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

Your options are:

  • Ensure prepend happens before alias_method
  • If you can control the alias_method invocation: rewrite to the modern & better prepend
  • If you can only control the prepend invocation: rewrite to the legacy alias_method
Posted by Dominik Schöler to makandra dev (2023-07-31 10:13)