On Friday, February 8, 2019 at 7:13:11 AM UTC-8, Janko Marohnić wrote: > > Hello Jeremy, > > When specifying that a dataset should eager load certain associations, we > don't always remember to call #all when retrieving records. We often > accidentally call #each or #map or `#to_a`, in which case nothing is eager > loaded. Given that we always want to call #all if we specified eager > loading, I'm looking for a way how to either prevent ourselves from calling > #each/#map/#to_a when we specified `.eager`, or to modify #each to > automatically call #all. > > I tried overriding #each, but since #all calls #each internally, it's a > bit tricky because I have no way of knowing whether #each was called by > #all or directly. Do you by any chance have any ideas how to achieve this? >
The eager_each plugin will internally call #all if you call #each on an eager loaded dataset. 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.
