Class: ActiveStorage::Downloader

Inherits:
Object
  • Object
show all
Defined in:
activestorage/lib/active_storage/downloader.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ Downloader

Returns a new instance of Downloader.



7
8
9
# File 'activestorage/lib/active_storage/downloader.rb', line 7

def initialize(service)
  @service = service
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service



5
6
7
# File 'activestorage/lib/active_storage/downloader.rb', line 5

def service
  @service
end

Instance Method Details

#open(key, checksum: nil, verify: true, name: "ActiveStorage-", tmpdir: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'activestorage/lib/active_storage/downloader.rb', line 11

def open(key, checksum: nil, verify: true, name: "ActiveStorage-", tmpdir: nil)
  open_tempfile(name, tmpdir) do |file|
    download key, file
    verify_integrity_of(file, checksum: checksum) if verify
    yield file
  end
end