M
Matt Bleh
Hi,
I'm writing a ruby library, under a module named "A". Since I provide
classes which share names with standard ruby classes (like Vector), this
way I avoid namespace pollution when requiring my library.
The problem is that I have an inner ("private") module "B", defined
under "A" where I have a bunch of methods defined that these classes
will use (I'm using RubyFFI).
But, since (as a user of my library) I would want to "include A" to
avoid the A:: prefix everywhere, the inner module "B" would be exposed
to the top-level.
I don't think it may be really problematic, but I think it may be a
common issue that others may face.
An example:
module A
# I provide a nice Vector implementation, to replace Ruby's
class Vector
def func
# ...
B::c_library_func(p)
# ...
end
end
module B
extend FFI::Library
attach_function :c_library_func, [ ointer ], :void
# and continues...
end
end
If I do:
include A
Now B is visible to the user, and it may end-up clashing with something
else.
Is there a guideline for these cases?
Thank you
I'm writing a ruby library, under a module named "A". Since I provide
classes which share names with standard ruby classes (like Vector), this
way I avoid namespace pollution when requiring my library.
The problem is that I have an inner ("private") module "B", defined
under "A" where I have a bunch of methods defined that these classes
will use (I'm using RubyFFI).
But, since (as a user of my library) I would want to "include A" to
avoid the A:: prefix everywhere, the inner module "B" would be exposed
to the top-level.
I don't think it may be really problematic, but I think it may be a
common issue that others may face.
An example:
module A
# I provide a nice Vector implementation, to replace Ruby's
class Vector
def func
# ...
B::c_library_func(p)
# ...
end
end
module B
extend FFI::Library
attach_function :c_library_func, [ ointer ], :void
# and continues...
end
end
If I do:
include A
Now B is visible to the user, and it may end-up clashing with something
else.
Is there a guideline for these cases?
Thank you