H
Hagbard Celine
Hey folks!
In my current project I try to load a module dynamically. Which is
basically no problem due to 'require` accepting filenames as well. My
problem is that I'd totally pollute my namespace. I thought of something
like the following:
def load_module(filename)
module NamespaceGuard # Just a random name
require filename
# Take a care of the loaded module
end
# My namespace is clean again
end
But Ruby's syntax apparently forbids module definitions in methods. I'd
be very glad if anyone could help me with this problem.
In my current project I try to load a module dynamically. Which is
basically no problem due to 'require` accepting filenames as well. My
problem is that I'd totally pollute my namespace. I thought of something
like the following:
def load_module(filename)
module NamespaceGuard # Just a random name
require filename
# Take a care of the loaded module
end
# My namespace is clean again
end
But Ruby's syntax apparently forbids module definitions in methods. I'd
be very glad if anyone could help me with this problem.