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.

Reply via email to