module Shrine::Plugins::Entity::AttacherClassMethods

  1. lib/shrine/plugins/entity.rb

Methods

Public Instance

  1. from_entity

Public Instance methods

from_entity(record, name, **options)

Initializes itself from an entity instance and attachment name.

photo.image_data #=> "{...}" # a file is attached

attacher = Attacher.from_entity(photo, :image)
attacher.file #=> #<Shrine::UploadedFile>
[show source]
   # File lib/shrine/plugins/entity.rb
84 def from_entity(record, name, **options)
85   attacher = new(**options)
86   attacher.load_entity(record, name)
87   attacher
88 end