From: Jean-denis Vauguet Date: 2010-03-21T15:39:42+09:00 Subject: Re: A plugin system using extend Thank you Josh. Actually I've already tested what you wrote and that's just fine as long as what you're redefining belongs to the Base::Server instance (that's the purpose of :extend). I posted a "mockup" of what I'd like in a single file: http://gist.github.com/339129 Basically, it's the "same" thing, but the purpose here is to redefine instance methods of *other classes* than the Base::Server which has the "include Plugins"; plus, to do so not for a particular instance of these classes, but for any of their instances. Problem is: in this situation, one cannot access a particular instance of the class to be altered within a given plugin. In my example, this means the Backward plugin should alter any instance of the Base::Speaker class once loaded. So you've got to work at the class level somehow (Base::Speaker). Using :extend at this class level seems useless to me here (it makes plugins redefinitions available as class methods for Base::Speaker, not instance's); and using :include does not override the class' instance methods, for the plugin module is added *before* the class in it's inheritance chain (say: [Base::Speaker, Base::Plugins::Backward::SpeakerRedef, Object, Kernel] once the Backward plugin is loaded). A workaround should be to undef (or alias) the original instance method when the plugin's module is :included, so that a call to the "original" method force the object to go finding the method in the plugin's module, but it feels clumsy to me. Maybe that's the only way to achieve this? After all, that was the point of alias_method_chain, wasn't it? Enlight me :) -- Posted via http://www.ruby-forum.com/.