Method: AbstractImporter::Strategies::InsertStrategy#insert_batch

Defined in:
lib/abstract_importer/strategies/insert_strategy.rb

#insert_batch(batch) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/abstract_importer/strategies/insert_strategy.rb', line 54

def insert_batch(batch)
  return if batch.empty?

  scope = collection.scope
  if scope.respond_to?(:proxy_association) && scope.proxy_association.reflection.through_reflection?
    scope = scope.klass
  end

  scope = invoke_callback(:prepare_scope, scope) || scope

  result = scope.public_send(@bulk_operation, batch, @insert_options)
  add_batch_to_id_map(result) if remap_ids?
end