Move membership invitation logic to class, use class in Rake task