Class: BulkImports::ExportService

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

Instance Method Summary collapse

Constructor Details

#initialize(portable:, user:) ⇒ ExportService

Returns a new instance of ExportService.


5
6
7
8
# File 'app/services/bulk_imports/export_service.rb', line 5

def initialize(portable:, user:)
  @portable = portable
  @current_user = user
end

Instance Method Details

#executeObject


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

def execute
  FileTransfer.config_for(portable).portable_relations.each do |relation|
    RelationExportWorker.perform_async(current_user.id, portable.id, portable.class.name, relation)
  end

  ServiceResponse.success
rescue StandardError => e
  ServiceResponse.error(
    message: e.class,
    http_status: :unprocessable_entity
  )
end