Class: BulkImports::TreeExportService

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

Instance Method Summary collapse

Constructor Details

#initialize(portable, export_path, relation) ⇒ TreeExportService

Returns a new instance of TreeExportService.


5
6
7
8
9
10
# File 'app/services/bulk_imports/tree_export_service.rb', line 5

def initialize(portable, export_path, relation)
  @portable = portable
  @export_path = export_path
  @relation = relation
  @config = FileTransfer.config_for(portable)
end

Instance Method Details

#executeObject

Raises:


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

def execute
  return serializer.serialize_root(config.class::SELF_RELATION) if self_relation?

  relation_definition = config.tree_relation_definition_for(relation)

  raise BulkImports::Error, 'Unsupported relation export type' unless relation_definition

  serializer.serialize_relation(relation_definition)
end

#exported_filenameObject


22
23
24
25
26
# File 'app/services/bulk_imports/tree_export_service.rb', line 22

def exported_filename
  return "#{relation}.json" if self_relation?

  "#{relation}.ndjson"
end