Re: Bulk Create for models?

2021-08-29 Thread Jeremy Evans
On Sun, Aug 29, 2021 at 8:48 PM Rob Galanakis wrote: > For now I went with something like this (my actual implementation isn't > quite so general): > > ``` > module Bulk > class Ref > attr_accessor :instance > def initialize(instance) > @instance = instance > end > end >

Re: Bulk Create for models?

2021-08-29 Thread Rob Galanakis
For now I went with something like this (my actual implementation isn't quite so general): ``` module Bulk class Ref attr_accessor :instance def initialize(instance) @instance = instance end end class Creator def initialize(model_cls) @model_cls = model_cls

Re: Bulk Create for models?

2021-08-29 Thread Jeremy Evans
On Sun, Aug 29, 2021 at 7:51 PM Rob Galanakis wrote: > I am trying to optimize some code to use bulk creation of models- on the > order of dozens, not hundreds, and I do still need models, so raw dataset > methods aren't suitable. > > I don't see a way to do this with Sequel- we have

Bulk Create for models?

2021-08-29 Thread Rob Galanakis
I am trying to optimize some code to use bulk creation of models- on the order of dozens, not hundreds, and I do still need models, so raw dataset methods aren't suitable. I don't see a way to do this with Sequel- we have Dataset#import and #multi_insert, and they can return an array of

Re: odd number of arguments for Hash

2021-08-29 Thread bee...@gmail.com
Thank you On Sunday, August 29, 2021 at 11:24:57 AM UTC-4 Jeremy Evans wrote: > On Sat, Aug 28, 2021 at 8:22 PM bee...@gmail.com wrote: > >> OK, understood. How do I insist on required parameters, named or >> otherwise? >> > > Probably easiest to check for values after calling super: > >

Re: odd number of arguments for Hash

2021-08-29 Thread Jeremy Evans
On Sat, Aug 28, 2021 at 8:22 PM bee...@gmail.com wrote: > OK, understood. How do I insist on required parameters, named or > otherwise? > Probably easiest to check for values after calling super: def initialize(values={}) super raise ArgumentError unless some_criteria # ...

Re: odd number of arguments for Hash

2021-08-29 Thread Marcelo Pereira
If you need to, you can call super in your initialize, passing the parameters the way Sequel models expect. Em dom., 29 de ago. de 2021 às 05:24, bee...@gmail.com escreveu: > Sorry...half way through a Saturday evening. I will try with a single > hash thrown, but how do I require such a