Class: SpreeCmCommissioner::Export
- Inherits:
-
Base
- Object
- Spree::Base
- Base
- SpreeCmCommissioner::Export
show all
- Includes:
- StoreMetadata
- Defined in:
- app/models/spree_cm_commissioner/export.rb
Instance Method Summary
collapse
Instance Method Details
#enqueue_export ⇒ Object
55
56
57
|
# File 'app/models/spree_cm_commissioner/export.rb', line 55
def enqueue_export
SpreeCmCommissioner::ExportJob.perform_later(export_id: id)
end
|
#export ⇒ Object
59
60
61
|
# File 'app/models/spree_cm_commissioner/export.rb', line 59
def export
raise NotImplementedError, 'Subclasses must implement the export method'
end
|
#exported_file_name ⇒ Object
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 ⇒ 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
return nil if ActiveStorage::Current.url_options.nil?
return nil if exported_file.blank?
exported_file.url(
expires_in: presigned_url_expires_in,
disposition: 'attachment'
)
end
|
#presigned_url_expires_in ⇒ Object
subclasses can override this to set different expiration time base on use case.
51
52
53
|
# File 'app/models/spree_cm_commissioner/export.rb', line 51
def presigned_url_expires_in
ENV.fetch('EXPORT_PRESIGNED_URL_EXPIRATION_MINUTES', '15').to_i.minutes
end
|
#set_uuid ⇒ Object
28
29
30
|
# File 'app/models/spree_cm_commissioner/export.rb', line 28
def set_uuid
self.uuid = SecureRandom.uuid
end
|