I think it would be more obvious when reading your code if you just called 
#sum_lines before calling #save, since it would't be clear why you were calling 
#save otherwise.

You *can* hook into other methods, like valid? and dirty?, but having 
side-effects here is probably not desirable:

before :dirty?, :sum_lines



On 01/07/2011, at 00:58, Joe Marty wrote:

> would be nice having this option:
>      before :save, :sum_lines, :mandatory => true
>  so it is always called, even if the object is not dirty.
> 
>  
> I have had this problem too, and haven't figured out the best way to solve it.
> 
> Another option would be to add another hook option like before/after 
> :save_attempt - which I suppose is very much like validate, except that 
> validations can happen or not happen independently of saves. 
> 
> -- 
> 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.

Reply via email to