Ruby require’s quirk is that, in general, it will only download one file once, if that file is accessible through several paths (for example, symbolic links), it can be requiredseveral times. This causes problems when there are such things as metaprogramming at the class level, or in general code that should be executed only once when loading a file, executing several times.
Is there a way, from within the definition of a Ruby class, to determine if a class has been previously defined? I thought that they could defined?or Object.const_getcould tell me, but from them it looks like as soon as a class is defined, as soon as it opens.
source
share