Paul Brannan <paul / atdesk.com> wrote in message news:<20011219135044.P6125 / atdesk.com>...
> I think almost all of us will agree that it's pretty ugly to do:
> 
>   class Foo
>     alias_method :old_foo, :foo
>     def foo
>       # do stuff
>       old_foo()
>     end
>   end
> 
> Well, I was playing around with define_method() last night, and I came
> up with this idea: when I include a module, an anonymous base class is
> created from the included module.  So if I could create a temporary
> module with one method, have that method be an alias for the method I
> want to override, and include it in the current class, then I could call
> the original function with a simple call to super()

Paul,

I was talking to matz about this issue at OOPSLA, and at least with
the current (CVS) version you should be able to do something like:

class Foo
    old_method = method(:foo)
    define_method(:foo) do
       #do stuff
       old_method.bind(self).call()
    end
end

This could obviously be generalized into an around() method of some
kind.