Hi all,
( I'm not a great ruby programer, I'm not a great
programmer at all,  but )

I need to write a sw in ruby that would allow people
adding plug-in/modules
to handle some event driven functions.
I can think of two ways of doing this:

#1 way

-create a Plugin class, with  methods that won't do
nothing 
(actually, I suppose this could be a mix-in)
-create the plugins as MyPlug<Plugin and redefine the
necessary methods 
-register MyPlug in an array
-define onEventXY as "proxy-methods" that would call
$PluginArray.each onEventXY
(maybe defining them as Plugin class methods)

I suppose this should work, but it seems that the last
step is too long and complex, and
anyway this approach would end calling  a lot of null
methods in any Plugin.

I even thought about having a check , something like 
$PluginArray.each do |x|
x.method if x.has_the_method(method) 
end

but this way I would add a check that actually would
be computationally worst than calling
a null method, and I would even add complexity to the
script, I suppose.

#2 way

-work on Method or create a myMethod class
-create a plugin (MyPlugMethod<myMethod or
myMethod.new) for each added method
-register the method in $MethodXYArray
-define onEventXY as "proxy-methods" that would call
$MethodXYArray.each ...

in this way I would lose a huge time loading the
plug-in files, writing them, 
and I don't even know how they could interact.

(I mean , eventX still could set a state that eventY
would unset,
and such things, but I don't know  if could be other
ways of interaction)


After all this raving I come to the question:
is there some Rubish Right Way (TM) to write  SW with
plug-in support?


PS
(sorry about my english)


=====
icq #69488917

______________________________________________________________________
Yahoo! Musica: notizie, recensioni, classifiche, speciali multimediali
http://it.yahoo.com/mail_it/foot/?http://it.music.yahoo.com/