What are good projects for metaprogramming?
During lecture, my students and I recreate Javascript objects in Ruby. In Javascript, these two lines are synonymous:

config['indent'] = 2;
config.indent = 2;


Ruby doesn't support this duality natively, but metaprogramming makes it possible.

We create a class AutoObject that internally stores a dictionary to hold all of the object's properties. Its method_missing consults this dictionary when something like config.indent is executed. If the method name suggests an assignment, it updates the dictionary. If it's a read of an existing property, it returns the value. Otherwise we raise an exception.

Once the automatic properties are in place, it's not much more work to add serialization and file I/O. By the end, we are reading and writing configuration files that are useful for any application.

ActiveRecord does something similar when it automatically creates an object and its interface based only on the database schema.