# frozen_string_literal: true class <%= @index_name %> < <%= @base_class %> module Collections class <%= @type.camelize %>Collection include Enumerable # @param params [Hash] List of parameters def initialize(**params) @params = params end # Find all <%= @type %> in batches # # @yield [Array<<%= @type.camelize %>>] # @see <%= @index_name %>::<%= @type.camelize %>#collection def each offset = 0 while (rows = find_all(offset)) break if rows.none? # You may preload associations before serialize them # associations = preload_associations!(rows) # yield(row, associations) offset += 1 yield(rows, **params) end protected attr_reader :params # @param offset [Number] Offset to start from def find_all(offset) # @TODO load data from persistent store end end end end end