
before_class_method :create not called in some cases
Reported by Guillaume Maury (giom) | May 2nd, 2008 @ 11:53 AM
before_class_method :create, :method
will call the method when the object is created with Model.create but won't call the method if one does Model.new.save
Of course one can do something like
http://pastie.textmate.org/priva...
but maybe it would be good to have a way to explicitly do something like before_create or before_update like in active record
Comments and changes to this ticket
-
Sam Smoot May 2nd, 2008 @ 03:03 PM
- State changed from new to invalid
Right. Model.create isn't called. update vs create is determined at the Repository level and the methods are called on the Adapter.
For now I'm thinking your work-around is the way I'd do it... a little less elegant maybe, but transparent. I like it.
I'm not against discussing some tweaks to it, but I'd be concerned about a consistent solution without adding a dozen hook methods unnecessarily.
Or maybe a dm-more plugin...
-
Guillaume Maury (giom) May 3rd, 2008 @ 01:41 AM
Just in the interest of giving credit to whom it belongs, the pastie with the workaround is afrench pastie :)
I'm maybe going to implement a dm-more plugin for this once dm 0.9 is released because it would be quite helpful when converting code for activerecord to datamapper...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »