[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Plugin Separation/Integration using method_missing

Naitik Shah

9/28/2007 4:45:00 AM

I'm trying to implement a framework where I have a concept of 'plugin
overlays'. They plug into an application which provides a well defined
external interface. The core of the plugin is a 'service' method that
potentially alters the applications state.

What I'm trying to achieve is to have the plugin run on 'top-of' the
application. Essentially, forward all unknown messages to the
Application as a fall-back (and fail there if needed).

I have some code attached which forms the basis of my current
implementation. Essentially use method_missing and forward messages to
the application.

As I understand, assignment to what looks can be a local variable in a
method will never go to method_missing, but instead create a local
variable. Alternatives for my case would be to explicitly create
mappings for these methods before hand, or explicitly call a method on
self.


Is this a bad idea?


My goal is to cleanly separate out code into reusable 'plugins' that
still have full access to the application. Also, plugins must be
isolated from each other.

I know explicitly referring to the application instead of having things
'fall-through' is an option.


Conceptually I'm thinking of this as a scope chain of sorts. On access
to an variable or a method call, we look for it in the Plugin (and all
its parents), and then the Application (and all its parents).


-Naitik

Attachments:
http://www.ruby-...attachment/46...

--
Posted via http://www.ruby-....