AbstractQueryFactoryFactories and alias_method_chain: The Ruby Way(yehudakatz.com)
yehudakatz.com
AbstractQueryFactoryFactories and alias_method_chain: The Ruby Way
http://yehudakatz.com/2010/02/15/abstractqueryfactoryfactories-and-alias_method_chain-the-ruby-way/
10 comments
You're actually reimplementing some parts of Ruby that already exist: http://ruby-doc.org/core-1.8.7/classes/UnboundMethod.html
I'm glad someone responded to the original post, after so many years of java, I can't really say I ever enjoyed factories they always seemed to solve a problem that was a weakness in the language itself.
I'm surprised anyone bothered; the original post was so very obviously troll bait. People who've been in the Ruby community as long as Yehuda should know better.
[deleted]
These monkey patches constitute my solution to the problem:
You use this as follows:
I'll admit that its implementation is pretty horrible, but I think the interface is much nicer: you pass in a function which specifies your new function in terms of the old one, which is always passed as the first argument.