Extending a mixed in module

I have extended FileTest with these methods

module FileTest
def FileTest.readable_file?(f)
file?(f) && readable?(f)
end
def FileTest.identical?(file1, file2)
File.absolute_path(file1) == File.absolute_path(file2) ||
File.stat(file1).ino == File.stat(file2).ino
end
end

The new methods are usable like this
FileTest.readable_file?(filename)
But why doesn’t
File.readable_file?(filename)
work? Class File mixes in FileTest and my understanding is that this
happens by reference via a proxy class. Why, then, are definitions
added to the mixed-in module not visible from the mixing-in class?

And incidentally, why are there both FileTest and File::Stat?

Michael

···


Michael Schuerig If at first you don’t succeed…
mailto:schuerig@acm.org try, try again.
http://www.schuerig.de/michael/ --Jerome Morrow, “Gattaca”

The new methods are usable like this
FileTest.readable_file?(filename)
But why doesn’t
File.readable_file?(filename)
work? Class File mixes in FileTest and my understanding is that this
happens by reference via a proxy class. Why, then, are definitions
added to the mixed-in module not visible from the mixing-in class?

FileTest isn’t mixed into File:

File.included_modules
==>[File::Constants, Enumerable, Kernel]

Reading the source in file.c I found out that the FileTests functions
are defined as module methods in FileTest and singleton methods in
File.

And incidentally, why are there both FileTest and File::Stat?

I have no idea.

···

On 2002-10-30 04:15:17 +0900, Michael Schuerig wrote:


Don’t you see that the whole aim of Newspeak is to narrow the range of
thought? In the end we shall make thoughtcrime literally impossible, because
there will be no words in which to express it.
– George Orwell, “1984”, 1948