class AWS::S3::ObjectCollection::BatchHelper

@api private
processes items in batches of 1k items

def add item

def add item
  @batch << item
  if @batch.size == @batch_size
    process_batch
    @batch = []
  end
  item
end

def after_batch &block

def after_batch &block
  @after_batch = block
end

def complete!

def complete!
  process_batch unless @batch.empty?
end

def initialize batch_size, &block

def initialize batch_size, &block
  @batch_size = batch_size
  @block = block
  @batch = []
end

def process_batch

def process_batch
  response = @block.call(@batch)
  @after_batch.call(response) if @after_batch
end