It's an interesting issue. dkubb's remark to me about it was: hooks for :save, 
:create, :update are not *method* hooks (even though it's easy to think they 
are). Conceptually they are *event* hooks, and should only run if that event 
actually happens. 

In the event of a clean resource, the :save *event* never happens, so with that 
in mind, it makes no sense for hooks to fire for an event that didn't happen.

Just some notes about the thinking behind the design.

-- Emmanuel

On Jun 30, 2011, at 12:56 PM, Javier wrote:

>> 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
> 
> Yes, that's what I was thinking, removing the hook from the model and
> call it from the outside.
> 
> I just thought that hooks were always executed, but that's not the
> case.
> 
> Thanks for the information anyway :)
> 
> -- 
> 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