Erik Veenstra wrote: >> Is it possible to execute a method in a specific context, > > As long as the objects are of the same class, you could use > Method#unbind and UnboundMethod#bind. If they aren't, you could > experiment with Method#to_proc. Thanks, I'll give it a try. >> @@foo = Generic.new > > Why?... I was trying to keep the class namespace clean and to consolidate the methods into their own space. The unbind/bind technique is interesting - now I tried making the generic object the same class, and doing this: def foo( *args ) method = @@foo.method( @@foo.find_method( args ) ) method.unbind.bind( self ).call( *args ) end But alas, I get: generic.rb:33:in `bind': singleton method called for a different object (TypeError) I guess I don't fully understand how singleton methods differ from normal methods. Thanks for all your time, this is just a curiosity not for a project per se. > gegroet, > Erik V. - http://www.erikveen.dds.nl/ > > ---------------------------------------------------------------- > > class Foo > def bar > self.object_id > end > end > > foo1 = Foo.new > foo2 = Foo.new > > p foo1.bar > p foo2.bar > > p foo1.method(:bar).unbind.bind(foo2).call > p Foo.instance_method(:bar).bind(foo2).call > > ----------------------------------------------------------------