From: johng Date: 2005-05-25T14:45:23+09:00 Subject: Re: Anonymous module undefined method error > more requirements on the file? you can do the same thing, you just > have to create an instance: > > -bash: [~]$ cat testdata > def foo > "foo!" > end > > -bash: [~]$ cat test.rb > data = File.read( "testdata" ) > aclass = Class.new > aclass.class_eval( data ) > a = aclass.new > puts a.foo > > -bash: [~]$ ruby test.rb > foo! I was able to get this to work great. I would like to have testdata contain a complete class definition (including base classes) and be able to call methods on it without knowing its name. Is there some way for the class inside testdata to "register" itself with the anonymous class instance "a"? I thought that I could just get the class to call a method and "a" would respond as it is the superclass. That didn't seem to work. Any help/pointers very much appreciated. John.