3 ms·
This is a fundamental part of the language, the idea that objects and classes are dynamic, not static. What I would say is that although we should have an extr
by braythwayt 11y ago
This is a fundamental part of the language, the idea that objects and classes are dynamic, not static.
What I would say is that although we should have an extremely good reason to employ these techniques in production, I believe that every professional Ruby programmer should be able to understand them and/or figure them out in a few minutes.
It’s not like we’re talking about obfuscated C.
- seivadmas 11y agoAgree with you 100%, and the ability to dynamically define methods is one of Ruby's great strengths. However, metaprogramming is a power that should be used wisely. When implemented unnecessarily it reduces readability (and probably performance) for no real gain. The devise source contains some great examples of metaprogramming used properly: https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb https://github.com/plataformatec/devise/blob/master/lib/devi...