From: Todd Burch Date: 2009-01-26T04:55:42+09:00 Subject: Re: unalias a method? Mike Gold wrote: > > class Foo > def hello > p "hi" > end > alias_method :hello2, :hello > end > > Foo.new.hello2 #=> "hi" > class Foo > remove_method :hello2 > end > Foo.new.hello2 #=> undefined method `hello2' Thanks Mike. Perhaps that's what I said, but that's not what I meant... ;) Sorry about that. I tried recreating my scenario with alias_method, and it seems as if it wasn't really a factor in my test. This is the sequence that I would like to happen: module Foo def Foo.hello p "Hi" end end # module #################### p "I expect to print hi:" Foo.hello #<== this works #################### module Foo def Foo.hello p "printing of hi is suppressed" end end #################### p "I expect to suppress printing of hi:" Foo.hello # <== this works #################### p "Now, I want to print hi again:" ###??? What needs to happen here? Foo.hello I'm assuming that alias_method is what I need to be using to temporarily "redirect" all my Foo.hello calls to do something different for a certain period of time, and finally I want to revert to the original behavior of Foo.hello. I used a module example, because that's what I'm using my real case, and I don't have access to the module source. Thanks, Todd -- Posted via http://www.ruby-forum.com/.