It looks like http://rom-rb.org already does this, hmm...
On Mon, Aug 21, 2017 at 3:53 PM Nick Griffiths <[email protected]> wrote: > Thanks Jeremy, > > The code example was to illustrate the separation rather than being a sane > way of using said library. I wrote it down very quickly before a meeting :) > > I'm going to play with it a little more, I'll try to remember to post > something back if it isn't too embarrassing. > > > Cheers, > Nick > > On Mon, Aug 21, 2017 at 3:48 PM Jeremy Evans <[email protected]> > wrote: > >> On Sunday, August 20, 2017 at 7:29:49 PM UTC-7, Nick wrote: >>> >>> I really like sequel, and I really like dry-types, and I'm not a big fan >>> of the active model pattern - has any one tried to write some integration >>> code to provide some persistence style glue between sequel and dry-types? >>> A quick google search turned up nothing... >>> >>> I'm wanting to be able to do something like: >>> >>> persistence = Sequel::DryTypes.new(cnx) >>> type = My::Type.new(:foo => 'bar') >>> persistence.save(type) >>> new_type = persistence.fetch(type.id) >>> >>> Anyone got any clues, tips or advice? :) >>> >> >> No experience here. I will say that this code example looks a little >> odd. I understand the advantages (and disadvantages) of separating >> persistence from modeling, but having the persistence code mutate the >> object passed in (to set the id) seems to go against the separation. After >> all, if the persistence layer would mutate the object, why would it mutate >> just the id and not the entire object? >> >> The separation between persistence and modeling makes more sense if you >> are doing: >> >> saved_type = persistence.save(type) >> new_type = persistence_fetch(saved_type.id) >> >> Or even better: >> >> new_type = persistence.save_and_fetch(type) >> >> assuming that save_and_fetch would apply the same optimization that >> Sequel::Model#save would do in regards to using INSERT ... RETURNING (or >> the equivalent for the database). >> >> 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 https://groups.google.com/group/sequel-talk. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
