views:

156

answers:

2

I was just over looking at this question. The first thought that popped to my head was that ruby must have some sort of "as" type keyword like Python's import to help avoid namespace pollution. I've googled a bit but it seems that it's recommended to wrap your code in modules to avoid namespace problems with ruby. This seems problematic because what if two modules have conflicting names.

So, any "as" type keywords for ruby's require?

+3  A: 

What I always do is start my modules with my company initials for work or my own initials for my personal projects.

module JWG_TwitterTools
.
. 
.
end
FannyPack
As @Paulo points out above, this only works if the source code is yours.
Mark
Excellent point. My point is that you can avoid conflicts with your own namespaces, and avoid others having conflicts when they use your code, by applying your own prefix to your libraries and gems. This is a 'best practices' kind of thing that will save you all sorts of grief and if everyone does it then it will cut the potential for conflicts to a minimum.
FannyPack
+2  A: 

In ruby 2.0, there will be mix (search for mix). But now, there is nothing like that... Simply use the full constant path.

Tass
@Tass, not much detail there, but still interesting. Thanks for the link. I'm not sure I know what you mean by "use the constant path", though.
Mark
`Foo::Bar` aka full path :-)
Tass