module Shrine::Plugins::RemoteUrl::AttacherMethods

  1. lib/shrine/plugins/remote_url.rb

Methods

Public Instance

  1. remote_url
  2. remote_url=

Public Instance methods

remote_url ()

Form builders require the reader as well.

[show source]
# File lib/shrine/plugins/remote_url.rb, line 120
def remote_url
  @remote_url
end
remote_url= (url)

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.

[show source]
# File lib/shrine/plugins/remote_url.rb, line 101
def remote_url=(url)
  return if url == ""

  begin
    downloaded_file = download(url)
  rescue => error
    download_error = error
  end

  if downloaded_file
    assign(downloaded_file)
  else
    message = download_error_message(url, download_error)
    errors.replace [message]
    @remote_url = url
  end
end