There are several restrictions on what you can do within a method
body.  For example, you can't define a constant, a class, or an
instance method (but you can define a singleton method, oddly enough).
 You can't create an alias or use undef.

What is the reason for these restrictions (and what is the reason for
the exception regarding singleton methods)?  It's usually possible to
get around the restrictions by calling eval from within a method body,
passing it a string that does what you want to accomplish.  Is it
simply that the current implementation of the parser isn't able to
handle these kinds of nested constructions?  Or was the idea to try to
discourage people from doing these things, since they tend to make
programs more difficult to understand?

Alan Stern