Module Sequel::Plugins::EagerEach::DatasetMethods
In: lib/sequel/plugins/eager_each.rb

Methods

all   columns!   each   single_record!  

Public Instance methods

If eager loading, clone the dataset and set a flag to let each know not to call all, to avoid the infinite loop.

[Source]

    # File lib/sequel/plugins/eager_each.rb, line 53
53:         def all(&block)
54:           if use_eager_all?
55:             clone(:all_called=>true).all(&block)
56:           else
57:             super
58:           end
59:         end

Don‘t call all when attempting to load the columns.

[Source]

    # File lib/sequel/plugins/eager_each.rb, line 33
33:         def columns!
34:           if use_eager_all?
35:             clone(:all_called=>true).columns!
36:           else
37:             super
38:           end
39:         end

Call all instead of each if eager loading, unless each is being called by all.

[Source]

    # File lib/sequel/plugins/eager_each.rb, line 43
43:         def each(&block)
44:           if use_eager_all?
45:             all(&block)
46:           else
47:             super
48:           end
49:         end

Handle eager loading when calling first and related methods. For eager_graph, this does an additional query after retrieving a single record, because otherwise the associated records won‘t get eager loaded correctly.

[Source]

    # File lib/sequel/plugins/eager_each.rb, line 64
64:         def single_record!
65:           if use_eager_all?
66:             obj = clone(:all_called=>true).all.first
67: 
68:             if opts[:eager_graph]
69:               obj = clone(:all_called=>true).where(obj.qualified_pk_hash).unlimited.all.first
70:             end
71: 
72:             obj
73:           else
74:             super
75:           end
76:         end

[Validate]