Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Using Module#const_missing for resolving "external" classes

Reply
Thread Tools

Using Module#const_missing for resolving "external" classes

 
 
Thomas
Guest
Posts: n/a
 
      09-01-2003
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
 
Reply With Quote
 
 
 
 
Thomas
Guest
Posts: n/a
 
      09-01-2003
> How would I go about doing this?

Never mind, I think I got it figured out.

Cheers,

Thomas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Using property() to extend Tkinter classes but Tkinter classesare old-style classes? Terry Reedy Python 5 11-30-2010 06:49 PM
how to link classes using pointers of their derived classes ivan.leben@gmail.com C++ 6 09-07-2006 07:00 AM
OOP casting classes (using one single variable for similar types of classes) roberts.noah@gmail.com C++ 8 01-07-2006 04:13 PM
Example of resolving an alias using Carbon.File module? fortepianissimo@gmail.com Python 1 01-21-2005 02:40 PM
Can I using reflection to get all child classes or classes undera package dynamically? Carfield Yim Java 1 05-31-2004 05:33 PM



Advertisments