Class: Para::ActiveStorageDownloader

Inherits:
Object
  • Object
show all
Includes:
ActiveStorage::Downloading
Defined in:
lib/para/active_storage_downloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachment) ⇒ ActiveStorageDownloader

Returns a new instance of ActiveStorageDownloader.



9
10
11
# File 'lib/para/active_storage_downloader.rb', line 9

def initialize(attachment)
  @attachment = attachment
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



5
6
7
# File 'lib/para/active_storage_downloader.rb', line 5

def attachment
  @attachment
end

Instance Method Details

#download_blob_to_tempfile(&block) ⇒ Object

For versions of ActiveStorage that don’t have an ActiveStorage::Downloading module, we define the method ourselves, as defined in the ActiveStorage::Analyzer and ActiveStorage::Previewer classes, which is simple enough to be copied here.



20
21
22
# File 'lib/para/active_storage_downloader.rb', line 20

def download_blob_to_tempfile(&block)
  blob.open tmpdir: Dir.tmpdir, &block
end