From: Daniel Berger Date: 2005-07-13T05:00:58+09:00 Subject: Re: Namespace conflict resolution Dema wrote: > Hi guys, > > This question is better explained with an example: > > I have the standard File class, right? Suppose I define another File > class within my own namespace: > > module MyNamespace > class File > ... > end > end > > Now, if I am on an irb session and I want to refer to my > MyNamespace::File class using only the short form 'File', I would do: > include MyNamespace > > How does Ruby decide which class to use when I reference 'File' in this > scope? (I've already tested and the original 'File' class is the chosen > class) > > How would I be able to temporarely replace the standard 'File' class in > the global Object namespace with my own File class and then revert it > back to the standard when I'm done? > > rgds > Dema > http://dema.ruby.com.br My general response would be: don't do that. My personal experience is that slapping existing Ruby classes under your own namespace is a bad idea. It's just a pain. The fact that you're trying to use the "short form" only reinforces that it's unnecessary. Just put your methods directly in the File class without the added namespace. Regards, Dan