I really like the idea of having a raise_on_save_failure option on my
resource. Though I think it should always default to false since its
would really mess up the control logic of controllers if the non-bang
save all of a sudden started throwing exceptions. Seems like a change
like this should be avoided even on a major release version.

Dan, I agree with your logic on using ! as an unsafe indicator,
however I think its worth considering future ActiveRecord switchers
(many who will try Datamapper when Rails3 is out). This is going to be
pretty unexpected behavior for them. It was pretty unexpected for me,
and I've been using Datamapper regularly for almost 9 months. I'm not
totally opposed to your approach, as I think its perfectly appropriate
theoretically. Just practically, it's going to cause many people, many
problems. Maybe we can just use a different method for plugin authors
(save_without_callbacks! or something) and call it good.

In the meantime, I guess I can just use "@model.save || raise" to
replicate my previous @model.save! functionality.


On Sep 26, 11:07 pm, "Dan Kubb (dkubb)" <[email protected]> wrote:
> Simon,
>
> > > The bang versions of the CRUD methods are "unsafe" and allow plugin
>
> > Phew! I'm glad I saw this post. I'd been using WRONGLY assuming it
> > meant the same thing as in AR.
>
> Yeah, I designed the "bang == unsafe" behavior in DM to match more
> closely how ruby core/stdlib libraries were designed:
>
>  http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist
>
> > I typically like things to fail fast rather than have checks all over the 
> > place. That doesn't seem to be idomatic DM though?
>
> I actually prefer the fail fast approach too.  That's how I write
> code, and how I've tried to write DM's API -- if you do something
> wrong I want it to explode immediately, or as early as possible.  I
> hate it when I do something wrong, but I don't find out until later,
> after the damage has been done.
>
> I've been thinking about this for some time, and I wonder if perhaps
> the approach Sequel uses for this might be better.  I believe they
> have a global, per-model, and per-resource method like
> "raise_on_save_failure" that they can set to true/false, and when true
> it will cause any save failures to raise an exception.  I believe the
> default in Sequel is true, but if I did add something like this to DM
> it would be false for a few minor releases to give everyone enough
> time to set it the way they want, and then we'd decide whether to turn
> it on or off by default.
>
> What do you think?
>
> --
>
> Dan
> (dkubb)
--~--~---------~--~----~------------~-------~--~----~
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