Class: SolidusImporter::Import

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/solidus_importer/import.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#importerObject

Returns the value of attribute importer.



7
8
9
# File 'app/models/solidus_importer/import.rb', line 7

def importer
  @importer
end

Class Method Details

.available_typesObject



43
44
45
# File 'app/models/solidus_importer/import.rb', line 43

def available_types
  SolidusImporter::Import.select(:import_type).order(:import_type).group(:import_type).pluck(:import_type)
end

Instance Method Details

#created_or_failed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/solidus_importer/import.rb', line 28

def created_or_failed?
  %w[created failed].include? state
end

#finished?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/solidus_importer/import.rb', line 32

def finished?
  rows.failed_or_completed.size == rows.size
end

#import_file=(path) ⇒ Object



36
37
38
39
40
# File 'app/models/solidus_importer/import.rb', line 36

def import_file=(path)
  raise SolidusImporter::Exception, 'Existing file required' if !path || !File.exist?(path)

  self.file = File.open(path, 'r')
end