Would it be possible to use const_missing to resolve external classes?
Ie, I imagine doing something like this

class Module
   def const_missing(aSymbol)
      # Look for aSymbol.to_s among the externally defined classes
      # If it is there return a ruby object that wraps it
   end
end

The problem is, how would you implement it, so it searches in the
right namespaces? Ruby searches through from the inner most scope an
outwards when it looks for a constant, and if it doesn't find it ends
up calling const_missing on the module where the constant is
referenced. Is there a way figure out exactly what scopes have been
searched for the constant and in what order?

If I could somehow get a complete ordered list of Modules and Classes
that are searched including those that have been (transitively)
included, that would make my day.

How would I go about doing this?

Cheers,

Thomas