module Shrine::Attacher::ClassMethods

Attributes

shrine_class[RW]

Returns the Shrine class that this attacher class is namespaced under.

Public Instance Methods

from_data(data, **options) click to toggle source

Initializes the attacher from a data hash generated from ‘Attacher#data`.

attacher = Attacher.from_data({ "id" => "...", "storage" => "...", "metadata" => { ... } })
attacher.file #=> #<Shrine::UploadedFile>
# File lib/shrine/attacher.rb, line 25
def from_data(data, **options)
  attacher = new(**options)
  attacher.load_data(data)
  attacher
end
inspect() click to toggle source

Since Attacher is anonymously subclassed when Shrine is subclassed, and then assigned to a constant of the Shrine subclass, make inspect reflect the likely name for the class.

# File lib/shrine/attacher.rb, line 17
def inspect
  "#{shrine_class.inspect}::Attacher"
end