ts <decoux / moulon.inra.fr> writes:

>>>>>> "M" == Matt Armstrong <matt / lickey.com> writes:
>
> M>         def do_substitute
> M>           module_eval { alias_method :do_it, :substitute_do_it }
> M>         end
>
>          def do_substitute
> 	    class << self
> 	       alias_method :do_it, :substitute_do_it
>             end
>          end

Thanks -- I also discovered instance_eval

    def do_substitute
      code <<-CODE
      class << self
        alias_method :do_it, :substitute_do_it
      end
      CODE
      instance_eval(code)
    end

I went this way because the code is dynamically generated (more
complex than the above example).