From: "David A. Black" Date: 2004-11-15T21:51:34+09:00 Subject: Kernel#singleton_class (was: Re: OpenStruct#update ?) Hi -- On Mon, 15 Nov 2004, Florian Gross wrote: > trans. (T. Onoma) wrote: > > > Sure. Okay first, basically what I was doing, given object o and data in hash > > h: > > > > h.each do |k,v| > > o.instance_variable_set("@#{k}", v) > > o.instance_eval <<-EOS > > def #{k}; @#{k}; end > > def #{k}=(x); @#{k}=x; end > > EOS > > end > > h.each do |k,v| > class << o; self; end.send(:attr_accessor, k) > o.k = v > end > > Maybe .meta_class and .meta_class_eval should really be part of Standard > Ruby... I've got an RCR in for singleton_class. (I know, the terminology is different, but it's the same idea :-) I still don't know what the perfect word would be for That Class.) I don't think a separate _class_eval method would be necessary or good. As with every other class, you could just call class_eval on the class object. I firmly believe that having a singleton_class method (or whatever it's called) would make it much, much easier for people to understand the whole design. See . David -- David A. Black dblack@wobblini.net