Class: NtqExcelsiorEngine::Import
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- NtqExcelsiorEngine::Import
- Defined in:
- app/models/ntq_excelsior_engine/import.rb
Instance Attribute Summary collapse
-
#async ⇒ Object
Returns the value of attribute async.
Instance Method Summary collapse
- #importer_klass ⇒ Object
- #process_import!(actions: NtqExcelsiorEngine.actions_on_create.map(&:to_s)) ⇒ Object
- #temp_file ⇒ Object
Instance Attribute Details
#async ⇒ Object
Returns the value of attribute async.
6 7 8 |
# File 'app/models/ntq_excelsior_engine/import.rb', line 6 def async @async end |
Instance Method Details
#importer_klass ⇒ Object
34 35 36 |
# File 'app/models/ntq_excelsior_engine/import.rb', line 34 def importer_klass NtqExcelsiorEngine.importers[import_type.to_sym] end |
#process_import!(actions: NtqExcelsiorEngine.actions_on_create.map(&:to_s)) ⇒ Object
38 39 40 41 42 43 |
# File 'app/models/ntq_excelsior_engine/import.rb', line 38 def process_import!(actions: NtqExcelsiorEngine.actions_on_create.map(&:to_s)) if async || (async.nil? && NtqExcelsiorEngine.async) job_id = NtqExcelsiorEngine::ProcessImportJob.perform_async(id, actions.join(',')) p "ASYNC #{job_id}" end end |
#temp_file ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/models/ntq_excelsior_engine/import.rb', line 24 def temp_file return @tmp if @tmp filename = file.blob.filename @tmp = Tempfile.new([filename.base, filename.extension_with_delimiter], binmode: true) @tmp.write(file.download) @tmp.rewind @tmp end |