Brilliant, thanks! Reading the reference implementation code, I realize my code wasn't thread-safe.
Best, Michael *Michael MONERAU* CEO & Founder Qontrol <https://www.qontrol.io> Le ven. 1 mai 2020 à 02:28, Jeremy Evans <[email protected]> a écrit : > On Thursday, April 30, 2020 at 3:20:00 PM UTC-7, Michael Monerau wrote: >> >> Hello, >> >> While reading the docs, I saw that part about freezing models & database >> in prod and testing: >> >> >> https://sequel.jeremyevans.net/rdoc/files/doc/code_order_rdoc.html#label-Finalize+Associations+and+Freeze+Model+Classes+and+Database >> >> Unless there is a feature I missed, there is no built-in way to get the >> list of registered models to freeze. >> >> I put together this simple plugin (code in this gist >> <https://gist.github.com/qortex/14fef1895ace338acd3d1c71e7b5fabf>) that >> allows a simple `freeze` method like in the doc: >> >> SequelPlugins::ListModels.models&.each(&:finalize_associations) >> SequelPlugins::ListModels.models&.each(&:freeze) >> DB.freeze >> >> I would be interested to have your thoughts on this, and if anybody has >> solved this in a more elegant / built-in way. >> >> Thanks a lot for awesome Sequel, code & docs are simply amazing. >> > > What you want is handled by the subclasses plugin. It allows you to do: > > Sequel::Model.freeze_descendants # finalizes associations before > freezing > > You need to load the subclasses plugin before creating the model > subclasses. > > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/sequel-talk/0520d088-6248-47f8-b8ad-c7eaf5c0f772%40googlegroups.com > <https://groups.google.com/d/msgid/sequel-talk/0520d088-6248-47f8-b8ad-c7eaf5c0f772%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/CAAkfp_S_6xDos16nw7UQxtMQxKPWr-U%3DH6y2iN%3D5zH_wr%2BWNKQ%40mail.gmail.com.
