# Plugin Separation/Integration using method\_missing

**URL:** <https://www.ruby-forum.com/t/plugin-separation-integration-using-method-missing/115751>\
**Category:** Ruby\
**Created:** [September 28, 2007, 6:44am UTC](https://www.ruby-forum.com/t/plugin-separation-integration-using-method-missing/115751 "2007-09-28T06:44:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daaku](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9e8a1a/32.png) [@daaku](https://www.ruby-forum.com/u/daaku)\
**Post date:** [September 28, 2007, 6:44am UTC](https://www.ruby-forum.com/t/plugin-separation-integration-using-method-missing/115751/1 "2007-09-28T06:44:37Z")

</div>

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
