module Shrine::Plugins::DataUri::AttacherMethods

  1. lib/shrine/plugins/data_uri.rb


Public Instance

  1. data_uri
  2. data_uri=

Public Instance methods

data_uri ()

Form builders require the reader as well.

[show source]
# File lib/shrine/plugins/data_uri.rb, line 165
def data_uri
data_uri= (uri)

Handles assignment of a data URI. If the regexp matches, it extracts the content type, decodes it, wrappes it in a StringIO and assigns it. If it fails, it sets the error message and assigns the uri in an instance variable so that it shows up on the UI.

[show source]
# File lib/shrine/plugins/data_uri.rb, line 152
def data_uri=(uri)
  return if uri == ""

  data_file = shrine_class.data_uri(uri)
rescue ParseError => error
  message = shrine_class.opts[:data_uri_error_message] || error.message
  message = if message.respond_to?(:call)
  errors.replace [message]
  @data_uri = uri