AgileVentures / osra

Sponsor orphans in Syria & ensure basic life & education requirements for Syrian children
MIT License
20 stars 39 forks source link

pt. III DestroySponsorship service object #324

Closed NikitaAvvakumov closed 9 years ago

NikitaAvvakumov commented 9 years ago

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, 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.

NikitaAvvakumov commented 9 years ago

Part IV merged