With a block eval.
This example is taken from Sequel, which creates accessor methods for the columns it finds when introspecting the database, which may contain spaces or other characters not valid in ruby literals.