spacepaste

  1.  
  2. class Assignment
  3. def transfer(person_id: nil)
  4. random = false
  5. if !person_id
  6. person_id = get_random_person.id
  7. random = true
  8. end
  9. @thing.update(assignee: person_id)
  10. rescue NotFound
  11. transfer(get_random_person(refresh: true).id)
  12. end
  13. private
  14. def get_random_person(refresh: false)
  15. @person = nil if refresh
  16. @person ||= begin
  17. RandomPerson.new
  18. end
  19. end
  20. end
  21.