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
e.g.
class MyTestController < ActionController:Base def test @ref = MyModule::MyClass.new({: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