If eager loading, clone the dataset and set a flag to let each know not to call all, to avoid the infinite loop.
# File lib/sequel/plugins/eager_each.rb, line 37 def all(&block) if use_eager_all? clone(:all_called=>true).all(&block) else super end end
Call all instead of each if eager loading, uless each is being called by all.
# File lib/sequel/plugins/eager_each.rb, line 27 def each(&block) if use_eager_all? all(&block) else super end end
Wether to use all when each is called, true when eager loading unless the flag has already been set.
# File lib/sequel/plugins/eager_each.rb, line 49 def use_eager_all? (opts[:eager] || opts[:eager_graph]) && !opts[:all_called] end