On Feb 28, 10:52 pm, Jeremy Evans <[email protected]> wrote:
> I suppose it would be possible to use datasets as hash values, as you
> suggest, even though hash values are currently used for recursive/
> chained eager loading.  That's obviously an easier way to get dynamic
> eager loading compared to my code above.  It would require changing
> the default eager loaders, and putting the dataset to use in the hash
> passed to the eager loaders.  You'd also need to deal with possible
> recursion when also specifying a dataset argument.  Those shouldn't be
> too difficult cases to handle, though.  After 3.21.0 is released
> tomorrow, give a shot a modifying the eager_load method to handle that
> case using your proposed API, and see how it works in your app.  If
> you find it works well, send in a patch with specs.

I gave this some more thought and think that instead of providing a
dataset, you can provide a proc that is called with default dataset
that would be used, and should return a dataset to be used:

  Albums.eager(:daily_sales_figures =>
    proc{|ds| ds.filter(...).select(...)})

Using callbacks in this way is much more flexible, and probably more
concise in most cases.  What do you think?

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to