Ruby Metaprogramming Episode 4: instance_eval and class_eval
Two of the workhorse methods of metaprogramming are
class_eval. They allow you to execute chunks of code dynamically. Here we’ll see how to use them.
- When to use one versus the other
- Breaking down barriers
- Creating methods on the fly, but without using closures
- Defining stuff in classes given a class object
- Writing DSLs in a block structure