On Sat, Apr 05, 2003 at 08:36:12PM +0900, Damphyr wrote:
> But then, how do we change the parameter to 
> extend to be able to say something like
> 
> module = myclass.very_clever_method_takes_string_returns_module(modulename)
> a = Foo.new
> a.extend module

That should work just fine - you can pass modules around like any other
object.

> In essence what I want is to be able to evaluate a string and find out 
> if it matches a symbol (or the texual representation of a symbol to be 
> more accurate) in my class space, and then return that symbol or the 
> object/class/module for that symbol

symbols are global, so "symbol in my class space" doesn't quite make sense.

Do you mean "does object X have a method of name S"? There are a number of
introspection techniques such as
  self.class.instance_methods
  self.singleton_methods

but maybe all you want is something simple like

   sym = :foo
   meth = begin
     self.method(sym)
   rescue NameError
     nil
   end

This will give you a method object if the object 'self' contains a method of
name <sym>. You can later call it using meth.call(args...)

Regards,

Brian.