From: daz Date: 2005-11-05T07:32:09+09:00 Subject: Re: Class and Mixin with same method name problem RK wrote: > petermichaux wrote: > > Robert Klemme wrote: > > > Now why doesn't the example below make two who_am_i calls? > > One to Burp and one to Debug. It only calls Burp. > > Wrong. Look again. :-) > Peter, you've annoyed Robert - he won't help you now ;-) If you go to the trouble of calling a method, you may as well do something with its return value rather than just losing it. module Debug def who_am_i 'Debug' end end module Burp def who_am_i 'Burp' end end module Throb # #def who_am_i # # 'Throb' # #end end class EightTrack include Burp include Throb include Debug def who_am_i wai = [self.class] ( self.class.ancestors - [Object, Kernel] - wai ).each do |a| ( wai << a.instance_method(:who_am_i).bind(self).call ) rescue nil end wai end end et = EightTrack.new p et.who_am_i # [EightTrack, "Debug", "Burp"] daz