Module: Sequel::Plugins::EagerEach::EagerDatasetMethods

Defined in:
lib/sequel/plugins/eager_each.rb

Overview

Methods added to eagerly loaded datasets when the eager_each plugin is in use.

Instance Method Summary collapse

Instance Method Details

#all(&block) ⇒ Object

Clone the dataset and set a flag to let #each know not to call #all, to avoid the infinite loop.



37
38
39
40
41
42
43
# File 'lib/sequel/plugins/eager_each.rb', line 37

def all(&block)
  if opts[:all_called]
    super
  else
    clone(:all_called=>true).all(&block)
  end
end

#each(&block) ⇒ Object

Call #all instead of #each unless #each is being called by #all.



27
28
29
30
31
32
33
# File 'lib/sequel/plugins/eager_each.rb', line 27

def each(&block)
  if opts[:all_called]
    super
  else
    all(&block)
  end
end