From: Yong Li Date: 2011-12-03T16:38:11+09:00 Subject: Re: Inverse Operation of Module#include Then, you probably can consider making different implementations as "objects" and switch these objects in A at run-time. class A def setImpl(implementation) @impl=implementation end def foo impl.foo end #other methods of the interface end class ImplB include B end class ImplC include C end #at run-time a = A.new a.setImpl(ImplB.new) a.foo #=> call b.foo a.setImpl(ImplC.new) a.foo #=> call c.foo a.setImpl(ImplB.new) a.foo #=> call b.foo of course, you may need further modifications if module B accesses A's private methods On Sat, Dec 3, 2011 at 1:54 AM, Su Zhang wrote: > On 12/2/2011 2:51 AM, Yong Li wrote: >> >> BTW, what do you want to achieve, switch interface at run-time or >> switch implementation at run-time? >> > > The latter. In my example code the interface `foo' is not changed but there > exists several implementations. > -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Li, Yong Fushan Road 450, Room 9A Pudong New Area, Shanghai, 200122 P.R.China phone: +86-15021003368 email: gilbertly@gmail.com =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=