Class: BulkImports::TreeExportService
- Inherits:
-
Object
- Object
- BulkImports::TreeExportService
- Defined in:
- app/services/bulk_imports/tree_export_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
- #exported_filename ⇒ Object
-
#initialize(portable, export_path, relation) ⇒ TreeExportService
constructor
A new instance of TreeExportService.
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
#execute ⇒ Object
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_filename ⇒ Object
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 |