开发者

DRY Rails Metaprogramming - Use Cases

开发者 https://www.devze.com 2023-02-04 03:08 出处:网络
So I\'ve running around my app, applying this particular use case for DRY\'ing your app via metaprogramming:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消