logandk/mongoid_denormalize — pull request #10 by jbbarth (2012-04-30 11:36:30+00:00)
Title: Feature : nullify denormalize_to values when the reference object destroyed

When denormalizing an attribute to a child object, it's common to "nullify" the reference in the child object when the parent one is destroyed. Then the denormalized fields in the child object should be nullified too if you want to keep a consistent state across your database.

I described it with a new `Category` model and an example in the spec, because I thought it would explain well what I mean (whereas destroying user leading to nullifying his posts' user_name is not obvious).

Let me know what you think. I'm totally open to put some more efforts into this, including :
* make the behavior optional, or add the ability to disable this behavior
* avoid unnecessary queries : when the relation is set to be `destructive?` (regarding mongoid definition), it might be useless to nullify denormalized fields

...but I'd like to know your opinion first. Thanks !