Hello,
I want to add a condition to a Magritte-described object that checks the whole object for consistency (and not just a single attribute). Is that possible?
Example: Think about creating a workgroup from some of the users of your site. The workgroup has a manager. The condition is that the manager must be one of the members of the workgroup.
I've tried to do this. I have two descriptions on the workgroup class side: one for the manager (saying that it can be any of the site's users) and one for the users (saying that this is a subset of all users). I can add a method #description to modify the standard description that is assembled from the description* methods on the class side. So I tried:
Workgroup>>description
^super description
addCondition: [:workgroup | workgroup users includes: workgroup manager]
labelled: 'Manager must be a member of the workgroup';
yourself
Alas, trying to edit an existing workgroup, I learned that the argument of the condition block is a MACheckedMemento, so I can't ask it for users.
What would be the best way to have this check everytime the work group is edited? Or should I just write the #manager: method such that the condition will be satisfied automatically?
Cheers
Matthias
PS: I want to say a big thank you, especially to Lukas, for the great answers on this list. I have learned something every time, and I was impressed when my questions on how to do something were answered with a patch.
PPS: No, this email is not a request for a patch :-)