use define_method instead of class eval