Part III of IV - replace model callbacks handling sponsorship events with service objects.
The main point of concern for me in undertaking this was the fact that the Sponsorship model had been made responsible for ensuring that pertinent Sponsor & Orphan objects were updated synchronously whenever the sponsorship changed (was created, destroyed or inactivated). Secondarily, though still importantly, both Sponsor & Orphan had become loaded with many methods that went well beyond the core responsibilities of an AR model, namely persistence, validations & associations.
Here, a DestroySponsorship service object is created following the patterns established in pts. I & II. Since upon sponsorship destruction an orphan's sponsorship status must be resolved based on its remaining sponsorship associations, a ResolveOrphanSponsorshipStatus service object is also created. This functionality is also used whenever an orphan is reactivated (status change from 'On Hold' or 'Inactive' to 'Active') - see pt. IV.
Do not merge!
Part III of IV - replace model callbacks handling sponsorship events with service objects.
The main point of concern for me in undertaking this was the fact that the Sponsorship model had been made responsible for ensuring that pertinent Sponsor & Orphan objects were updated synchronously whenever the sponsorship changed (was created, destroyed or inactivated). Secondarily, though still importantly, both Sponsor & Orphan had become loaded with many methods that went well beyond the core responsibilities of an AR model, namely persistence, validations & associations.
Here, a
DestroySponsorship
service object is created following the patterns established in pts. I & II. Since upon sponsorship destruction an orphan's sponsorship status must be resolved based on its remaining sponsorship associations, aResolveOrphanSponsorshipStatus
service object is also created. This functionality is also used whenever an orphan is reactivated (status change from 'On Hold' or 'Inactive' to 'Active') - see pt. IV.