Class: SpreeCmCommissioner::Export

Inherits:
Base
  • Object
show all
Includes:
StoreMetadata
Defined in:
app/models/spree_cm_commissioner/export.rb

Instance Method Summary collapse

Instance Method Details

#enqueue_exportObject



50
51
52
# File 'app/models/spree_cm_commissioner/export.rb', line 50

def enqueue_export
  SpreeCmCommissioner::ExportJob.perform_later(export_id: id)
end

#exportObject

Raises:

  • (NotImplementedError)


54
55
56
# File 'app/models/spree_cm_commissioner/export.rb', line 54

def export
  raise NotImplementedError, 'Subclasses must implement the export method'
end

#exported_file_nameObject



32
33
34
35
36
# File 'app/models/spree_cm_commissioner/export.rb', line 32

def exported_file_name
  return nil if exported_file.blank?

  exported_file.filename.to_s
end

#exported_file_url(expires_in: 15.minutes) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/spree_cm_commissioner/export.rb', line 38

def exported_file_url(expires_in: 15.minutes)
  # Controllers should set ActiveStorage::Current.url_options in a before_action
  # See GuestJsonGzipsController for an example
  return nil if ActiveStorage::Current.url_options.nil?
  return nil if exported_file.blank?

  exported_file.url(
    expires_in: expires_in,
    disposition: 'attachment'
  )
end

#set_uuidObject



28
29
30
# File 'app/models/spree_cm_commissioner/export.rb', line 28

def set_uuid
  self.uuid = SecureRandom.uuid
end