Class: BulkCreateIntegrationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/bulk_create_integration_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(integration, batch, association) ⇒ BulkCreateIntegrationService

Returns a new instance of BulkCreateIntegrationService.


4
5
6
7
8
# File 'app/services/bulk_create_integration_service.rb', line 4

def initialize(integration, batch, association)
  @integration = integration
  @batch = batch
  @association = association
end

Instance Method Details

#executeObject


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/bulk_create_integration_service.rb', line 10

def execute
  service_list = ServiceList.new(batch, integration_hash, association).to_array

  Integration.transaction do
    results = bulk_insert(*service_list)

    if integration.data_fields_present?
      data_list = DataList.new(results, data_fields_hash, integration.data_fields.class).to_array

      bulk_insert(*data_list)
    end
  end
end