Clearing a plugins instance variables on each request

I'm trying to move some of my application's code into a plugin,
specifically the part that deals with web analytics. Some of the
features allow the controller to fire events that get displayed in the
views as JS code through a partial or helper. I'm currently doing this
with instance variables, but when I move it to a class or instance
variable of my plugin class, it persists between requests. I guess
this makes sense because the plugin is loaded on startup.

What I have working is making it an instance variable of
ApplicationController:

class MyPlugin
   ApplicationController.instance_variable_set("@my_plugin_event",
nil)
end

which is cleared on every request. It works, but I feel like I'm
working against the grain here and doing something wrong.

Is what I'm doing OK, or is there a better way? To make it clear, I
want to be able to do something like "notice_event('blah')" in the
controller of the main application, and have the plugin's helper know
about "blah" for the current request, but not the next request.

Thanks

Sean

Sean,

Would flash.now work?

http://apidock.com/rails/ActionController/Flash/FlashHash/now

Anthony Crumley

http://commonthread.com

It would seem to do what I'm looking for, though was the flash meant
for objects? Either way, I'll look at the implementation to see if I
can use similar methods.

Thanks,

Sean

Sean,

I think flash.now would be fine for objects because it is only there during the request and is not persisted.

Anthony Crumley
http://commonthread.com