If you can anticipate method names, it is better to declare them dynamically than rely on method_missing, because method_missing carries a performance penalty. For example, suppose you want to extend a database descriptor to be able to access database views using this syntax:
selected_view_rows = @dbh.viewname( :column => value, ... )
Instead of relying on method_missing on the database descriptor and sending the method name to the database as the name of the view, you could pre-define all the views in the database and then iterate over them to create the "viewname" methods on @dbh.
Pistos Nov 15 '08 at 18:00 2008-11-15 18:00
source share