Thanks to visit codestin.com
Credit goes to github.com

Skip to content

dougyouch/batching

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

batching

Adds in_batches to enumerable objects

requirement: enumerable objects must have the each_with_index method

Example:

ids = get_all_ids()

# adds the in_batches method to this object
ids.extend(Batching)

# use the in_batches method to fetch 100 ids at a time
ids.in_batches(batch_size: 100) do |batch|
  response = bulk_lookup(batch)

  JSON.parse(response.body).each do |result|
    # now process each result
  end
end

About

Batch processing for Enumerable

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages