Class: Tartarus::RemoteStorage::Glacier::RegisterUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/tartarus/remote_storage/glacier/register_upload.rb

Instance Method Summary collapse

Constructor Details

#initialize(archive_registry_factory, clock: Time) ⇒ RegisterUpload

Returns a new instance of RegisterUpload.



8
9
10
11
# File 'lib/tartarus/remote_storage/glacier/register_upload.rb', line 8

def initialize(archive_registry_factory, clock: Time)
  @archive_registry_factory = archive_registry_factory
  @clock = clock
end

Instance Method Details

#register(glacier_response, archivable_model, tenant_id_field, tenant_id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tartarus/remote_storage/glacier/register_upload.rb', line 13

def register(glacier_response, archivable_model, tenant_id_field, tenant_id)
  archive_registry_factory.new.tap do |archive_registry|
    archive_registry.glacier_location = glacier_response.location
    archive_registry.glacier_checksum = glacier_response.checksum
    archive_registry.glacier_archive_id = glacier_response.archive_id
    archive_registry.archivable_model = archivable_model
    archive_registry.tenant_id_field = tenant_id_field
    archive_registry.tenant_id = tenant_id
    archive_registry.completed_at = clock.now
    archive_registry.save!
  end
end