Class: Shrine::Storage::Url
- Inherits:
-
Object
- Object
- Shrine::Storage::Url
- Defined in:
- lib/shrine/storage/url.rb
Defined Under Namespace
Classes: Downloader
Instance Method Summary collapse
- #delete(id) ⇒ Object
- #download(id) ⇒ Object
- #exists?(id) ⇒ Boolean
-
#initialize(downloader: :down) ⇒ Url
constructor
A new instance of Url.
- #open(id) ⇒ Object
- #upload(io, id) ⇒ Object
- #url(id, **options) ⇒ Object
Constructor Details
#initialize(downloader: :down) ⇒ Url
Returns a new instance of Url.
7 8 9 |
# File 'lib/shrine/storage/url.rb', line 7 def initialize(downloader: :down) @downloader = Downloader.new(downloader) end |
Instance Method Details
#delete(id) ⇒ Object
32 33 34 |
# File 'lib/shrine/storage/url.rb', line 32 def delete(id) request(:delete, id) end |
#download(id) ⇒ Object
15 16 17 |
# File 'lib/shrine/storage/url.rb', line 15 def download(id) @downloader.download(id) end |
#exists?(id) ⇒ Boolean
23 24 25 26 |
# File 'lib/shrine/storage/url.rb', line 23 def exists?(id) response = request(:head, id) (200..299).cover?(response.code.to_i) end |
#open(id) ⇒ Object
19 20 21 |
# File 'lib/shrine/storage/url.rb', line 19 def open(id) @downloader.open(id) end |
#upload(io, id) ⇒ Object
11 12 13 |
# File 'lib/shrine/storage/url.rb', line 11 def upload(io, id, **) id.replace(io.url) end |
#url(id, **options) ⇒ Object
28 29 30 |
# File 'lib/shrine/storage/url.rb', line 28 def url(id, **) id end |