From: Space Ship Traveller Date: 2010-03-21T12:38:37+09:00 Subject: Re: A plugin system using extend I'm not sure if this helps, but I did something like this before: http://www.oriontransfer.co.nz/blog/2009-10/loading-anonymous-ruby-classes/index Kind regards, Samuel On 21/03/2010, at 3:46 PM, Jean-denis Vauguet wrote: > Hi. > > I tried to design a simple plugin system using :extend called upon > instance (http://ruby-doc.org/core/classes/Object.html#M000335 usual > documented behavior), so as to inject some methods redefinitions while > keeping the ability to call super in order to fall back on the default > behavior if needed. > > It looks like this: http://gist.github.com/339025 > It works as expected, as one can see by reading the commented output at > the end of the file: the inheritance chain is altered, with the plugin > "subclassing" the original class of the plugin receiver. > > Yet, I tried to introduce some modularity in the system, so I went for: > http://gist.github.com/339028 > It fails but I don't understand why. The inheritance chain is not > altered. > I tried to use :include instead of :extend, which gives merely the same > behavior (overwriting instance methods), but this time the plugin module > is added as the parent of the original class within the inheritance > chain, so it is useless for the purpose ;) > > I'll be glad if someone could give me a hint on this :) > Thank you! > -- > Posted via http://www.ruby-forum.com/. >