Hello, it's more theoretical question, in my case it causes some
problems, I can workaround it but it not seems to be the right way.
Here's the problem:
There's an object with :owner (username, String) and :viewers (array
of usernames) keys. It's supposed that viewers always should include
the object owner.
To implement it we'll override :owner= method, it'll check and add
object owner to list of viewers.
And it works fine, until you try to load previously saved object,
you'll then get two owner names in viewers instead just one.
Theoretically, persistence should return the same object as it took.
It shouldn't build object using public API.
Sure, we can easily workaround this, rename method, or use internal
state check in method body. But this workaround looks like a kind of
hack.
But maybe I'm missing something and there's a good reason to do it
this way?
Thanks, Alex.
PS here's the code responsible for this in MM (keys.rb)
if respond_to?(writer_method)
self.send(writer_method, value)
else
self[name.to_s] = value
end
to alter it behavior we just need to comment some lines.
--
You received this message because you are subscribed to the Google
Groups "MongoMapper" group.
For more options, visit this group at
http://groups.google.com/group/mongomapper?hl=en?hl=en