Writing a DSL in Ruby

An internal DSL is just Ruby that reads like a little language of its own. RSpec, Rake and Sinatra are all built this way. Here's how to build one yourself, from a naive first cut to the clean instance_eval pattern the real ones use.