Reputation: 24108
How it is possible to only expose one module or a class from a Ruby gem and close everything else?
For example, in a my-math
library, I only want to expose Math
module, but not any other, such as Math::Utils
or similar.
I want to enforce one and only one way of using the gem.
At least making it hard to access internal classes will help (even munging the names at runtime will be better than open-access).
Upvotes: 0
Views: 329
Reputation: 168199
Not clear what you are trying to do, but if you want private constants, why not just declare them as so?
module Namespace
module Secret
end
private_constant :Secret
Secret # => Namespace::Secret
end
Namespace::Secret # => NameError. Private constant Namespace::Secret referenced.
Upvotes: 2