Could RewriteRails Make ActiveRecord Mundane?
A thought crossed my mind: Many people complain about Ruby on Rails' use of "magic," things like all of the automatically generated methods and so forth. The most obvious cases are controllers and ActiveRecord models (from here in I'll call these "models" even though we both know you can have models that are not ActiveRecord instances).
Consider model classes. A few declarations...
acts_as_magical... And the model class gains a whole bunch of class and instance methods, plus often a whole bunch of
method_missing behaviours that "behave like" methods. Some people complain it is hard to figure out what methods a model really has.
What if RewriteRails were to rewrite ActiveRecord model class declarations to "mundane-ify" these magical methods? In other words, after a class has been loaded and all of the magic performed, RewriteRails writes out a
.rb file that has the source code for all of the magic methods as if the programmer had written them in by hand.
.rb file can be placed somewhere that Rails can't find it, this is a case of documentation. Now a programmer can read the mundane-ified
.rb file to get an idea of what methods the model class actually has.
Just a thought...
NEW! Kestrels, Quirky Birds, and Hopeless Egocentricity, all of my writing about combinators, collected into one convenient and inexpensive e-book!