From: Drew Olson Date: 2008-03-06T14:25:37+09:00 Subject: Re: How to create a class in callers context?? Drew Olson wrote: > DMisener wrote: >> 1) What's the correct way to doing this? >> 2) I would have thought the non-qualified class references would have >> generated exceptions. >> 3) What is the warning message trying to convey. > > Here's my crack at this, not sure this is what you're trying to do: Had a small typo, here's the fixed example: def generate &name eval("self",name.binding).class.class_eval <<-EOS class #{name.call} def to_s "#{name.call}" end end EOS end class Universe def initialize generate{:Planet} end end generate{:Thing} Universe.new puts Universe::Planet.new puts Thing.new -- Posted via http://www.ruby-forum.com/.