Some patterns, approaches, and “spells” for metaprogramming in Ruby.
Here’s a definition from Metapgramming Ruby 2:
Metaprogramming is writing code that manipulates language constructs at runtime.
Unlike in C, which has a distinction between compile time (language constructs available) and runtime (machine code), Ruby doesn’t have compile time at all. Most Ruby constructs are available at runtime making it a very metaprogramming friendly language.
Below are my notes in the form of Ruby metaprogramming patterns, approaches, and “spells” inspired by Metapgramming Ruby 2.