So I've running around my app, applying this particular use case for DRY'ing your app via metaprogramming:
http://rails-bestpractices.com/posts/16-dry-metaprogramming
In what other ways are you applying metaprogramming to keep your开发者_开发问答 app DRY?
I wrote a gem called to_lang which makes use of this type of dynamic method definition. It adds a bunch of methods to strings in the form to_language
which all call a single method with different parameters. ToLang::StringMethods
in particular is where this magic happens. Doing the same thing without metaprogramming would require the definition of hundreds of methods.
精彩评论