From: ara.t.howard@... Date: 2006-01-12T01:05:17+09:00 Subject: Re: how can I give a name to an anonymous class On Thu, 12 Jan 2006 sayoyo@yahoo.com wrote: > Hi, > > I'm try to create a generic anonymous class, and I want to set the > class name of the class, however I can't find a function which allow me > to do this, the only way I can do this is actually assigner the newly > create class to a constant. the classname will be (in my case) > GenActRec::className. > > Does someone know how to remove the "GenActRec::" ??? > > Does someone know is there another way to do this???? > > this is my generic class: > > class GenActRec < ActiveRecord::Base > > def self.buildNewTableClass(className, tableName) > genClass = Class.new(GenActRec) > const_set("#{className.to_s}", genClass) > genClass.set_table_name tableName > genClass.reset_column_information() > return genClass > end > > end harp:~ > cat a.rb class A c = Class::new do def foo 42 end end ::B = c Object::const_set 'B2', c end p B::new.foo p B2::new.foo harp:~ > ruby a.rb 42 42 -a -- strong and healthy, who thinks of sickness until it strikes like lightning? preoccupied with the world, who thinks of death, until it arrives like thunder? -- milarepa