module_function and helpers

Would core accept a patch that exposes helper methods (that don’t depend on ActionView state) via module_function?

The particular use case is that I have other objects that from time to time need access to a single helper method (like, say, #truncate). Including the entire TextHelper seems a bit heavy handed when all I need is access to a single method.

I would much rather do ActionView::Helpers::TextHelper.truncate(…) if it were possible.

Does this seem interesting / useful to anyone else?



I don’t have strong opinion about it but I fear this would give the wrong message to our users.

I don’t think we should take in consideration the number of methods you are including when you include a helper module. It just doesn’t matter in the most cases.

I believe there’s good precedent in ruby core/stdlib for this pattern.

But I worry that it would be more confusing (/ difficult to document) for us to be widely inconsistent.

I guess I’d need a feel for what proportion of our helpers would be module_function candidates. If it’s a good number, then it does seem worth considering. If it’s relatively few (and I suspect it might be?), then maybe not so much.


Ok, I’ll take a look at this over the weekend.