From: Mark Hahn Date: 2001-11-01T00:58:32+09:00 Subject: [ruby-talk:23969] Re: Overiding a method in another module Thanks. It kind of bothers me that I may have hundreds of lines of Ruby that need to be eval'd when I know eval is slow. This seems like a bit of a kludge. My code will look funny to have eval around every method. Whenever I smell a kludge, I always must ask is it me or the language. I think the answer to this lies in whether what I am trying to do is an "acceptable OO practice". Is it acceptable to want to add methods to someone else's module? Here is the situation that I am facing (see below). I want to add method m_2 to class C1 and make sure instances of C2 (any any other subclass of C1) respond to m_2. I cannot subclass C1 to accomplish this because I have no way to change C2 to subclass my new subclass. I cannot change the source of M1 because of the license. Even if there wasn't a license issue, isn't reusability all about using other code without changing it? module M1 << This is other person's module class C1 def m_1 ... end end class C2 < C1 ... end end module M2 << This is my module class M1::C1 def m_2 << I need instances of C2 to call this ... end end end I don't see how even multiple inheritance would help this situation. Can someone tell me a "clean", non-eval way of doing this? How do other languages handle this? -----Original Message----- From: David Alan Black [mailto:dblack@candle.superlink.net] Sent: Tuesday, October 30, 2001 5:29 PM To: ruby-talk ML Subject: [ruby-talk:23895] Re: Overiding a method in another module On Wed, 31 Oct 2001, David Alan Black wrote: > You can do this: [...] > M1::C1.class_eval <