From: Joel VanderWerf Date: 2003-01-22T03:52:44+09:00 Subject: Re: Mixins Gennady wrote: > I am completely lost -- it looks like it is not possible to redefine a > method at all with a mixin: > > class Test > def foo > puts "Test#foo" > end > end > > module Mixin > def foo > puts "Mixin#foo" > end > def bar > puts "Mixin#bar" > end > end > > class Test > include Mixin > end > > Test.new.foo #==> Test#foo > Test.new.bar #==> Mixin#bar > > So new method are added just fine, however a method I would like to > redefine stays the same. Is it how it was supposed to work? And how to > actually do redefine a method? Should there be any tricks involved, like > aliasing? Test.ancestors #==> [Test, Mixin, Object, Kernel] So actually, your Test#foo is replacing Mixin#foo, because Test occurs before Mixin on the method search path. class Test def foo super end end Test.new.foo #==> Mixin#foo