Class: ActiveStorageDownloader

Inherits:
Object
  • Object
show all
Defined in:
lib/clowne_active_storage/helpers/active_storage_downloader.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blob, tempdir: nil) ⇒ ActiveStorageDownloader

Returns a new instance of ActiveStorageDownloader.



7
8
9
10
# File 'lib/clowne_active_storage/helpers/active_storage_downloader.rb', line 7

def initialize(blob, tempdir: nil)
  @blob    = blob
  @tempdir = tempdir
end

Instance Attribute Details

#blobObject (readonly)

Returns the value of attribute blob.



6
7
8
# File 'lib/clowne_active_storage/helpers/active_storage_downloader.rb', line 6

def blob
  @blob
end

#tempdirObject (readonly)

Returns the value of attribute tempdir.



6
7
8
# File 'lib/clowne_active_storage/helpers/active_storage_downloader.rb', line 6

def tempdir
  @tempdir
end

Instance Method Details

#download_blob_to_tempfileObject



12
13
14
15
16
17
18
# File 'lib/clowne_active_storage/helpers/active_storage_downloader.rb', line 12

def download_blob_to_tempfile
  open_tempfile do |file|
    download_blob_to file
    verify_integrity_of file
    yield file
  end
end