On Fri, 5 Jan 2001, Nathaniel Talbott wrote:

> The only problem is, it doesn't look like there is a way to trap the
> definition of a method, and I also can't seem to find a way to define a
> method dynamically. It seems that this is a 'special' thing in Ruby, as
> opposed to just another operation on an object. My (probably naive) feature
> request is to make defining a method just an operation on a Module, as
> opposed to a 'special' behavior that can't be modified/overridden.

Actually, Module has a method_added hook that gets called immediately
after the definition of a method.  It would be possible to, for example,
use alias_method to append the number of arguments to the method's
name... as each overloaded version of the method was defined, you'd lose
the original definition, but you'd keep the alias.  You could then
redefine the original name as your dispatching function, which would call
the appropriate alias... as for defining this method dynamically, there's
always class_eval.