extract multi tenancy mechanism to a gem