3 ms·
> You can always read the actual implementation in your IDE Doesn't Rail's use of metaprogramming mean that often there isn't a simple static implementation of
by chrisseaton 6y ago
> You can always read the actual implementation in your IDE
Doesn't Rail's use of metaprogramming mean that often there isn't a simple static implementation of a method in the source code that you can go and find?
- pantulis 6y agoYes, but it just implies that you cannot rely on grepping the source code. You know the relevant "method_missing" implementation is somewhere, and you can make an educated guess as where to look for it.
- chrisseaton 6y agoI think I’m pretty well informed about Ruby metaprogramming but I still really struggle to read through the magic sometimes. I can appreciate it’s somewhat impenetrable to beginners.
- Dirlewanger 6y agoSure, but who the hell's going to read that, honestly? All the metaprogramming crap was my biggest hurdle when learning Ruby/Rails at the same time, and also figuring out what was Ruby and what was Rails. Rails actually does a great job of naturally extending Ruby so much that most of the helper modules in activesupport feel native. Also, Rails has top-tier documentation, including listing out all the dynamic methods for each database field.
- flippinburgers 6y agoYes and it makes moving through any non-trivial rails codebase a total drag.
- toomanybeersies 6y agoYea, but the documentation of said metaprogramming is generally quite comprehensive (with some exceptions).
- blacktriangle 6y agoIn fairness they've been moving away from a lot of those methods. For example the whole find_by_<attr_name> dynamic methods have been replaced with find_by(attr_name: value). And while you can't find the method code itself, for example the generated code to access a has_many relationship, you can pretty easily find the meta programming that will generate it by following the class method name.