From: Robert Klemme Date: 2005-11-05T06:42:09+09:00 Subject: Re: Class and Mixin with same method name problem petermichaux@yahoo.com wrote: > Robert Klemme wrote: >> petermichaux@yahoo.com wrote: >>> How do I call the Burp whoAmI? method? >> >> You don't (although you could with >> Burp.instance_method(:whoAmI?).bind(self).call). Messing like this >> with names is not advisable. > > Good to know that there is a way to do this. Too bad it is so messy > though. I'm thinking about using two Rails plugins in one model class. > Since rails has a magic after_find callback method I was thinking > about using this in each plugin since the plugins can be used > independently. Since my model must call both of these methods I will > have a third after_find callback method in the model that calls the > other two. I don't know Rails so I can't comment on this. I just would assume that DHH would have thought of this scenario. At least it sounds reasonable. Or you're abusing these plugins. > 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. :-) >> Note also that by >> convention a) methods ending in a question mark are reserved for >> boolean >> queries and b) Ruby uses lowe_case_method_names. :-) > > Good to know. I just cut and pasted the example from the the first > edition of Ruby Programming > > http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_modules.html Indeed. Then that's a sub optimal example. :-) > Peter > > > module Debug > def who_am_i > "Debug" > end > end > > module Burp > def who_am_i > "Burp" > end > end > > class EightTrack > include Burp > include Debug > def who_am_i > Debug.instance_method(:who_am_i).bind(self).call > Burp.instance_method(:who_am_i).bind(self).call > end > end > > et = EightTrack.new > > p et.who_am_i Kind regards robert