Skip to content

Instantly share code, notes, and snippets.

@marionzualo
Created December 14, 2016 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marionzualo/e597464390b0fcb41012fa237e128b92 to your computer and use it in GitHub Desktop.
Save marionzualo/e597464390b0fcb41012fa237e128b92 to your computer and use it in GitHub Desktop.
Fibers second example
def process_batch(batch)
p batch
end
# this method runs in a background job
def complex_operation_in_background
find_in_batches do |batch|
# the complex operation on the given batch
process_batch(batch)
end
end
# Execution in the terminal
# >> complex_operation_in_background
# ["Vhils", "AKACORLEONE"]
# ["Pixel Pancho", "+-"]
# ["Kruella D'Enfer", "Tamara Alves"]
# ["Add Fuel", "MAR"]
# ["Eime", "Bordalo II"]
# ["Felipe Pantone", "Ernest Zacharevic"]
# ["Wasted Rita", "Sainer"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment