Class: AWS::S3::ObjectCollection::BatchHelper
- Inherits:
-
Object
- Object
- AWS::S3::ObjectCollection::BatchHelper
- Defined in:
- lib/aws/s3/object_collection.rb
Overview
processes items in batches of 1k items
Instance Method Summary collapse
- #add(item) ⇒ Object
- #after_batch(&block) ⇒ Object
- #complete! ⇒ Object
-
#initialize(batch_size, &block) ⇒ BatchHelper
constructor
A new instance of BatchHelper.
Constructor Details
#initialize(batch_size, &block) ⇒ BatchHelper
Returns a new instance of BatchHelper.
303 304 305 306 307 |
# File 'lib/aws/s3/object_collection.rb', line 303 def initialize batch_size, &block @batch_size = batch_size @block = block @batch = [] end |
Instance Method Details
#add(item) ⇒ Object
313 314 315 316 317 318 319 320 |
# File 'lib/aws/s3/object_collection.rb', line 313 def add item @batch << item if @batch.size == @batch_size process_batch @batch = [] end item end |
#after_batch(&block) ⇒ Object
309 310 311 |
# File 'lib/aws/s3/object_collection.rb', line 309 def after_batch &block @after_batch = block end |
#complete! ⇒ Object
322 323 324 |
# File 'lib/aws/s3/object_collection.rb', line 322 def complete! process_batch unless @batch.empty? end |