has_many
. In this presentation, Dave Thomas (PragDave) focuses on the Ruby features that make metaprogramming possible:- Class definitions are active - they get executed
This allows to execute custom code when a class gets first loaded. - All method calls have a receiver, i.e. a
self
object
A crucial fact in Ruby - Dave explains howself
some methods of metaprogramming work with manipulatingself
. - Classes are objects too
- Open and singleton classes - it's always possible to add members to classes
eval
flexibly with bindings and more.Check out "MetaProgramming Ruby".