On Mon, Aug 31, 2009 at 2:24 PM, Yusuke ENDOH<mame / tsg.ne.jp> wrote: > Hi, > > 2009/9/1 Carl Lerche <clerche / engineyard.com>: > >> This causes pain when you are using a ruby library that does not >> assume that you will be extending classes. Rails "solved" this problem using >> alias_method_chain, but this method can cause confusion. > ... > > Then, I guess that what we really need is a method wrapping feature: > > ¨Βμασσ Πεςσοξ > ¨Βεζιξείνετθοδ¨Ίσπεαλ© δο όομδίνετθοδ¬ χοςδσό > old_method is a Method of original definition > ¨Βμδίνετθοδ®γαμμ¨Ά£ϋ χοςδύ΅Ά© > ¨Βξδ > ¨Βξδ > ¨Βεςσοξ®ξεχ®σπεαλ¨ΆνατϊΆ£½Άνατϊ΅ Yusuke-san, Are you familiar with alias_method_chain in Rails which Carl mentioned. This is a common rails extension idiom which you'd use like this module Exclaimer def speak_with_exclaimer(words) speak_with_exclaimer("#{words}!") end def.self.included(base) base.alias_method_chain :speak, :exclaimer end end and alias_method_chain aliases the existing speak method to send_without_exclaimer, and then the speak_with_exclaimer method to speak This allows independently developed class extension modules to be composed, but it can be a bit confusing at times, particularly when debugging because of the aliasing. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale