From: 7stud -- Date: 2009-09-14T03:25:20+09:00 Subject: Re: module to overwrite method defined via define_method Gaspard Bucher wrote: > Hi List ! > > I found a tricky thing: if you use define_method and then include a > module that contains a method with the same name, the method in the > module is just ignored. > > Why is that so ? > By the way, you can get the lookup order using the ancestors method: module Redef def foo puts "'foo' from module" end end class A define_method("foo") do puts "'foo' from define_method" end include Redef end p A.ancestors --output:-- [A, Redef, Object, Kernel] Although, ancestors() doesn't include the singleton classes: module Redef def foo puts "'foo' from module" end end class A def foo puts "foo from class A" end def initialize class << self include Redef end end end a = A.new a.foo p A.ancestors --output:-- [A, Object, Kernel] -- Posted via http://www.ruby-forum.com/.