I'm working on Ruby on Rails. There is a feature in our app where doctors can "claim" cases for themselves.
I can either have the doctor perform the action and update the plate, or I can have the doctor send itself to the plate and have the plate update itself.
Should objects update itself? It just seems cleaner to me, but I'm not sure. Or maybe I'm overthinking?
First case, doctor only:
def claim(plate)
plate.claimed = true
plate.doctor_id = id
plate.save
end
This is the second case (doctor sends itself to the plate):
#doctor
def claim(plate)
plate.claimed_by(self)
end
#plate
def claimed_by(doctor)
self.claimed = true
self.doctor_id = doctor.id
self.save
end