Signed: everyone who's ever used a DSL which could have been written better as a couple of dozen functions.
Ruby is a really bad language to write good DSLs in. Metaprogramming is an awkward replacement for better DSL facilities.
Maybe this book can demonstrate better techniques?
DSLs should be looked at as syntactic sugar for object instantiation. Language methods should set the object's state or run an instance method. Object behavior goes in the object's class.
I'm looking at one of my DSLs, it's a module with a parse method that takes a file with a default argument to the common "XXXXfile" that I see used a lot for DSLs. It opens the file and module_eval's the code. I use instance and module variables to hold state in the execution context of the DSL.
If you stick to this pattern you'll find a DSL easy to manage. I use it as a replacement for instantiating objects with YAML files, which I find brittle. I hate maintaining those, but a DSL will give me just the right amount of indirection. I can express the objects exactly how I want them to be expressed, which is a big win for me.
I had /some/ bad experiences with some DSL, but most of my experiences with them were pretty good (even those who I didn't write).
I can't remember the joke but the tagline goes, "Code I didn't write" anyone?
attr_reader foo
The 'foo' above would evaluate to the contents of the variable 'foo'. So, you have to do this: attr_reader :foo
Because we cannot control how this code evaluated, we must quote 'foo'. This greatly limits what we can express.http://www.infoq.com/presentations/kilmer-ruby-dsls
Good stuff from a guy who's done some pretty massive DSLs on DARPA projects.