summaryrefslogtreecommitdiff
path: root/app/models/concerns/each_batch.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/concerns/each_batch.rb')
-rw-r--r--app/models/concerns/each_batch.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/concerns/each_batch.rb b/app/models/concerns/each_batch.rb
index 6ddbb8da1a9..6baa9edc263 100644
--- a/app/models/concerns/each_batch.rb
+++ b/app/models/concerns/each_batch.rb
@@ -38,6 +38,10 @@ module EachBatch
# of - The number of rows to retrieve per batch.
# column - The column to use for ordering the batches.
def each_batch(of: 1000, column: primary_key)
+ unless block_given?
+ return to_enum(__method__, of: of, column: column).lazy
+ end
+
unless column
raise ArgumentError,
'the column: argument must be set to a column name to use for ordering rows'