From: Brian Candler Date: 2011-04-17T06:14:52+09:00 Subject: Re: looking for an "inversion" pattern Fearless Fool wrote in post #992929: > I'm sure there's a clean way to do this in Ruby, but I haven't figured > it out. > > I'd like to create a method +foo+ that transforms: > > my_obj.foo.some_method(*args) > > to > > MyClass.some_method(my_obj, *args) Not sure, but would bound or unbound methods help you? bound_method = my_obj.method(:foo) bound_method.call(*args) unbound_method = my_obj.class.instance_method(:foo) unbound_method.bind(my_obj).call(*args) -- Posted via http://www.ruby-forum.com/.