module Shrine::Attacher::ClassMethods

  1. lib/shrine/attacher.rb

Methods

Public Instance

  1. from_data
  2. inspect
  3. shrine_class

Attributes

shrine_class [RW]

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

Public Instance methods

from_data(data, **options)

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

attacher = Attacher.from_data({ "id" => "...", "storage" => "...", "metadata" => { ... } })
attacher.file #=> #<Shrine::UploadedFile>
[show source]
   # File lib/shrine/attacher.rb
25 def from_data(data, **options)
26   attacher = new(**options)
27   attacher.load_data(data)
28   attacher
29 end
inspect()

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.

[show source]
   # File lib/shrine/attacher.rb
17 def inspect
18   "#{shrine_class.inspect}::Attacher"
19 end