module Shrine::Plugins::DataUri::AttacherMethods

  1. lib/shrine/plugins/data_uri.rb

Methods

Public Instance

  1. assign_data_uri
  2. data_uri
  3. data_uri=

Public Instance methods

assign_data_uri(uri, **options)

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
106 def assign_data_uri(uri, **options)
107   return if uri == "" || uri.nil?
108 
109   data_file = shrine_class.data_uri(uri)
110   attach_cached(data_file, **options)
111 rescue ParseError => error
112   errors.clear << data_uri_error_messsage(uri, error)
113   false
114 end
data_uri()

Used by <name>_data_uri attachment method.

[show source]
    # File lib/shrine/plugins/data_uri.rb
123 def data_uri
124   @data_uri
125 end
data_uri=(uri)

Used by <name>_data_uri= attachment method.

[show source]
    # File lib/shrine/plugins/data_uri.rb
117 def data_uri=(uri)
118   assign_data_uri(uri)
119   @data_uri = uri
120 end