Magic to pass reference to a controller

I'm implementing a helper library which provide both view helpers and controller helpers. To save the end user from having to specifically pass in a reference to self on every call I was wondering if there was a way for a class to get access to the calling controller object automagically.

One suggestion was Thread.current[:controller] .. but that sounds a bit nasty


class MyTestController < ActionController:Base   def test     @ref ={:a_load_of_settings => 'go here'})   end end

module MyModule   class MyClass     def initialize(settings ={})       #I need a reference to the controller     end   end end

Wouldn't it be more natural to write the helper methods in modules that you'd mix into the controller using extend and include?