On Mon, 10 Oct 2005 17:21:51 +0900 "S.Z." <zbl / operamail.com> wrote: > I am playing with a Synchronized class that automates resource locking > (code snippet can be found here: > http://www.rubygarden.org/ruby?MultiThreading). > One issue arised is how to overload all (or particular) Object's (or > some ancestor's) methods by the automated way? > Syncronized extraction looks like this: > > class Syncronized > def initialize( klass, *args ) > @obj= klass::new( *args ); > end > > def to_s() @obj.to_s(); end > # What about clone(), taint(), and other? > end > > It is hard work to type all the Objecs's methods by hand in spite of > their bodies are the same. > What is the better choice? What about the "methods" method? You get an Array whith all the method-names of the current object. Maybe something like this class Sync def initialze (klass, *args) @object = klass::new(*args) @object.methods.each do |m| def m(a) object.m(a) end end end I know, this won't run - just an idea. -- > "not using Ruby is punishment enough" > -- James Britt, 8.5.2005, ruby-talk / ruby-lang.org