Actually.. the $loaded_files array, is nothing more than an array of strings. It does NOT matter whether the strings are pathnames to existing files, or non-existing files, or just some strings representing unique "already loaded flags".
What I mean is that the file_loaded() and file_loaded?() methods, do not do any testing to determine if the argument is a valid pathname.
- to save space (memory)
- to be sure that the "loaded keys" are unique
- to side-step the fact that __FILE__ does not work inside scrambled rubies
I have begun to set my "already loaded" arguments to a qualified namespace string, like:
I do not put the file extension as they may distro' as .rb or .rbs and it's not important anyway.
So, let's say my namespace is Boozer, and the plugin is Gadget, and the file sets up menu commands:
Noone else is using my namespace, so the string should be unique. Even for me it should be unique, because I include the plugin name, and files only ever load once (in normal usage. ie, not debugging.)
So to use your example, the following strings would be unique:
Furthermore... nothing really says that we MUST use the global $loaded_files array. (It's an invention of the SU DevTeam.)
If you are coding within your own unique toplevel "Author"/"Company" namespace... you can define your own "already loaded" string tag array, as a module variable, named whatever you like.
Then define getter and setter methods (or copy & modify the two from "sketchup.rb",) into your toplevel module.
Here's a template (now tested, and updated to v2.0.0) to do this, as a mixin module: