On Tuesday, June 2, 2015 at 3:20:20 AM UTC-7, DaVinci wrote:
>
> El lunes 01 de junio, Jeremy Evans escribió:
> > * A delay_add_association plugin has been added, for delaying add_*
> > method calls for associations until after the receiver has been
> > saved, if the receiver is a new object. Example:
> >
> > artist = Artist.new(:name=>'Foo')
> > artist.add_album(Album.new(:name=>'Bar'))
> > # No database queries yet
> >
> > artist.save # Saves artist, then album
>
> Hi.
>
> Can I use the same behaviour when artist is not new? I'd like to save
> later my
> objects in one atomic transaction, so I need to do assignment first and
> save
> later.
>
> I'd like a similar mechanism for remove_* and remove_all_* methods.
>
Currently, this is just for new objects. That's why it only deals with
add_* methods, because remove_* and remove_all_* wouldn't make sense for
new objects.
It's possible we could add a more general delay_associations plugin that
delays add_*, remove_*, and remove_all_* association methods until save for
both new and existing objects. However, that's a major behavior change and
would break a lot of existing code that wasn't designed for use with the
plugin, so I'm not too keen on the idea. Note that you can already do what
you want using instance_hooks:
obj = Model[1]
obj.after_save_hook{obj.add_foo(Foo[2])}
obj.after_save_hook{obj.remove_foo(Foo[3])}
obj.after_save_hook{obj.remove_all_foos}
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.