If you want the object to be dirty in this way, make it dirty by actually invoking your logic on it during the save of the child.
In the child (Line ?): after :create, :denormalize_parent def denormalize_parent parent.line_count += 1 end Or something to that effect. The object is genuinely dirty in this case. On 02/07/2011, at 03:16, mltsy wrote: > I think the real question here is, if you have some data particular to > a relationship that DataMapper doesn't handle automatically, for > instance, if you need to store the sum of .lines on your model > directly (for faster lookup, or whatever), how can you ensure that > always gets updated when the collection .lines is changed? > > Essentially, it would be nice to have DataMapper consider an object > dirty if a particular collection has changed. Perhaps there's a way > to modify the dirty? method to check for that? I'm not certain. But > that seems to get more at the root of the issue, doesn't it? > > On Jun 30, 5:02 pm, Emmanuel Gomez <[email protected]> wrote: >> On Jun 30, 2011, at 3:00 PM, Javier wrote: >> >>> Don't worry, I'm gonna call the method from the outside, i'm not going >>> to hook it. >> >> Shoot... I totally didn't even read your name and just wrote what I thought >> I remembered. I am red-in-the-face embarrassed. >> >> Please accept my apologies, Javier. >> >> -- Emmanuel > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
