Plugin Separation/Integration using method_missing

N

Naitik Shah

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-forum.com/attachment/462/scope.rb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,337
Members
48,014
Latest member
saradhi

Latest Threads

Top