Use define_method instead of eval-ing a string

It avoids the need for escaping the interpolations.