Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. module ChewyPostgresCursorAdapter
  2.  
  3. def import_scope(scope, options)
  4. result = true
  5.  
  6. objects = []
  7. index = 0
  8. scope.each_instance(block_size: options[:batch_size]) do |instance|
  9. objects << instance
  10.  
  11. if index >= options[:batch_size]
  12. result &= yield grouped_objects(objects)
  13. index = 0
  14. end
  15. index += 1
  16. end
  17.  
  18. result
  19. end
  20.  
  21. end
  22.  
  23. Chewy::Type::Adapter::ActiveRecord.prepend(ChewyPostgresCursorAdapter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement