Module: Shrine::Plugins::RemoteUrl::AttacherMethods
- Defined in:
- lib/shrine/plugins/remote_url.rb
Instance Method Summary collapse
-
#assign_remote_url(url, downloader: {}, **options) ⇒ Object
Downloads the remote file and assigns it.
-
#remote_url ⇒ Object
Used by ‘<name>_data_uri` attachment method.
-
#remote_url=(url) ⇒ Object
Used by ‘<name>_data_uri=` attachment method.
Instance Method Details
#assign_remote_url(url, downloader: {}, **options) ⇒ Object
Downloads the remote file and assigns it. If download failed, sets the error message and assigns the url to an instance variable so that it shows up in the form.
87 88 89 90 91 92 93 94 95 |
# File 'lib/shrine/plugins/remote_url.rb', line 87 def assign_remote_url(url, downloader: {}, **) return if url == "" || url.nil? downloaded_file = shrine_class.remote_url(url, **downloader) attach_cached(downloaded_file, **) rescue DownloadError => error errors.clear << (url, error) false end |
#remote_url ⇒ Object
Used by ‘<name>_data_uri` attachment method.
104 105 106 |
# File 'lib/shrine/plugins/remote_url.rb', line 104 def remote_url @remote_url end |
#remote_url=(url) ⇒ Object
Used by ‘<name>_data_uri=` attachment method.
98 99 100 101 |
# File 'lib/shrine/plugins/remote_url.rb', line 98 def remote_url=(url) assign_remote_url(url) @remote_url = url end |