The Magic of Class-level Instance Variables
This article was published on Ruby Magic.
In a previous Ruby Magic, we figured out how to reliably inject modules into classes by overwriting its .new
method, allowing us to wrap methods with additional behavior.
This time, we’re taking it one step further by extracting that behaviour into a module of its own so we can reuse it. We’ll build a Wrappable
module that handles the class extension for us, and we’ll learn all about class-level...