Ruby Metaprogramming Episode 5: Nine Examples of Metaprogramming

Posted in Development on July 12, 2008


Ruby Metaprogramming Episode 5: Nine Examples of Metaprogramming

Here’s where all the theory and practice comes together! We’ll take a simple problem and find nine different ways of attacking it using metaprogramming techniques.

  • Adding behavior directly inside the class
  • Using subclassing to add behavior
  • Subclassing with a generator using Class.new
  • Using a ghost class
  • Ghost class with a generator using class_eval
  • Rewrite the method with alias_method
  • Rewrite using a module
  • Rewrite using bind
  • Writing a DSL in a block

Watch Video

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming