module Sequel::Plugins::EagerEach::DatasetMethods

  1. lib/sequel/plugins/eager_each.rb

Methods

Public Instance

  1. all
  2. columns!
  3. each
  4. single_record!

Public Instance methods

all(&block)

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

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

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

[show source]
   # File lib/sequel/plugins/eager_each.rb
33 def columns!
34   if use_eager_all?
35     clone(:all_called=>true).columns!
36   else
37     super
38   end
39 end
each(&block)

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

[show source]
   # File lib/sequel/plugins/eager_each.rb
43 def each(&block)
44   if use_eager_all?
45     all(&block)
46   else
47     super
48   end
49 end
single_record!()

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.

[show source]
   # File lib/sequel/plugins/eager_each.rb
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