Reputation: 355
Let's say I have a method
in my ApplicationHelper
:
module ApplicationHelper
def a
do something
end
end
and I have a module in my lib folder:
module MyModule
def do_another_thing
# How can I use the method a here?
# I know that I can include the `ApplicationHelper` here, but I don't want to pollute my module with unrelated functions
end
end
Upvotes: 0
Views: 131
Reputation: 24617
You can mark that a
method as module_function
like so:
module ApplicationHelper
def a
do something
end
module_function :a
end
and then use it like ApplicationHelper.a
Upvotes: 2