class AWS::S3::ObjectCollection::BatchHelper
processes items in batches of 1k items @private
Public Class Methods
new(batch_size, &block)
click to toggle source
# File lib/aws/s3/object_collection.rb, line 321 def initialize batch_size, &block @batch_size = batch_size @block = block @batch = [] end
Public Instance Methods
add(item)
click to toggle source
# File lib/aws/s3/object_collection.rb, line 331 def add item @batch << item if @batch.size == @batch_size process_batch @batch = [] end item end
after_batch(&block)
click to toggle source
# File lib/aws/s3/object_collection.rb, line 327 def after_batch &block @after_batch = block end
complete!()
click to toggle source
# File lib/aws/s3/object_collection.rb, line 340 def complete! process_batch unless @batch.empty? end
Protected Instance Methods
process_batch()
click to toggle source
# File lib/aws/s3/object_collection.rb, line 345 def process_batch response = @block.call(@batch) @after_batch.call(response) if @after_batch end