Loading delegates in Rails View Helpers on to instance objects

Not sure if this should be done, but I’m writing some excel reports in ruby. In the rxls views, i’m finding that i refer to @report all the time.

In order to make my life easier i created a bunch of methods in the ReportsHelper for the base ReportsController. But i’m finding that i’m essentially defining delegates that point straight to my @report object. It makes my reports views more readable.

I wanted to find some way to load at least some of these methods as delegates. I was thinking about using self.included on the ReportsHelper module and loading them onto the class there.

I’m trying to look through ActionPack to see where these are loaded, but no dice. I’m worried about any magic that might be going on. Also, I’m just curious as to how and when these are loaded. Any good places to start?

You could just do:

delegate :something, :to => “@report