From: James Edward Gray II Date: 2010-03-22T03:16:29+09:00 Subject: Re: A plugin system using extend On Mar 21, 2010, at 12:44 PM, Jean-denis Vauguet wrote: > James Edward Gray II wrote: >> On Mar 21, 2010, at 2:13 AM, Jean-denis Vauguet wrote: >> >>> behavior of any instance without the need for aliasing. Same behavior as >>> my standalone and Josh codes, but same flexibility as my previous gist >>> attempted to achieve. >>> >>> I'll give it a try when I get the time to, unless I'm told this is BS ;) >> >> If I understand what you are saying correctly, I've used this exact >> strategy in the past. >> >> I allowed plugins to register themselves on the class object (you can >> also do that automatically as they are defined with an inherited hook), >> and then I just extended all instances with the registered plugins as >> they were created. >> >> It worked great and felt very natural to me when using it. >> >> James Edward Gray II > > Thank you for this feedback. You understood well I guess. This is good > pattern IMO too: you both get rid of dirty aliasing, and enable clean > inheritance with super. I did not have the time to try it out yet, but I > guess it should just work :) If it performs zell, I'll try to make it > more generic (a kind of "Pluginable" gem?). > > By the way, would you have any code snippet to illustrate the pattern? > That could come in handy when refactoring my code, for I'm sure you're > definitely more skilled at writing this kind of stuff than I currently > am ;) Sure. I added some code like that to Prawn a while back (though I don't think they kept it): http://github.com/JEG2/prawn/commit/7e25bafe16f508a080a41979bfe25b47f97f0a5e I hope that helps. James Edward Gray II