In Ramon's blog [1] he mentions:
"When creating a description for that collection, I can
specify my custom #accessor: rather than using the default
#selectorAccessor:
which then writes to my domain object with #addUser: and
#removeUser:."
Looking at the code, I don't see how this is done. Isn't the
write accessor going to get a complete collection? Is the
idea to just diff the received collection from the one the
object had and make calls to #add and #remove as appropriate,
or is there a way to only be told about the new objects in
the collection?
Thanks,
Jason
That's exactly what I do. When I encapsulate a collection, I always provide
the following
#pluralCopyOfCollection
#addX:
#removeX:
So...
#people
#addPerson:
#removePerson:
This doesn't work with Magritte expecting to be able to set the whole
collection, so I use a custom accessor that removes items not contained in
the new collection, and adds items not contained in the old collection. It
requires a little reflection and a pluralize method to infer the collection
name from the singular selector it's invoked with, i.e. #person for above
sample.
Ramon Leon
http://onsmalltalk.com