From: Gennady Date: 2003-01-22T03:28:25+09:00 Subject: Mixins This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C2C137.D3CB6700 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 #=3D=3D> Test#foo Test.new.bar #=3D=3D> 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? Thank you, Gennady ------=_NextPart_000_0014_01C2C137.D3CB6700 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I am completely lost -- it looks like = it is not=20 possible to redefine a method at all with a mixin:
 
class Test
  def foo
     puts=20 "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  #=3D=3D> = Test#foo
Test.new.bar  #=3D=3D> = Mixin#bar
 
So new method are added just fine, = however a method=20 I would like to redefine stays the same. Is it how it was supposed to = work? And=20 how to actually do redefine a method? Should there be any = tricks=20 involved, like aliasing?
 
Thank you,
Gennady
------=_NextPart_000_0014_01C2C137.D3CB6700--