Maybe I am doing something wrong but if I use `Sequel::Model.freeze_descendents` then the block is evaluated immediately when model class is loaded and self refers to a model Class...
Dne středa 15. července 2020 16:39:58 UTC+2 Jeremy Evans napsal(a): > > On Wednesday, July 15, 2020 at 6:07:39 AM UTC-7, Petr Kaleta wrote: >> >> Hello, >> please have a look on the following code snippet >> >> class Foo < Sequel:Model >> one_to_many :bars do |ds| >> # how can I get here a reference to a current Foo model instance? Or >> at least current Foo model primary_key >> end >> end >> >> Btw I am using >> Sequel::Model.freeze_descendents >> >> Thanks a lot >> > > The block is evaluated in the context of the model instance, so self > refers to the model instance at that point. Note that relying on that will > mean that eager loading will not work without a custom :eager_loader option. > > 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/973ac7f0-d7e4-4e21-98f4-9346daf5d412o%40googlegroups.com.
