Class: Alchemy::PictureThumb::Create
- Inherits:
-
Object
- Object
- Alchemy::PictureThumb::Create
- Defined in:
- app/models/alchemy/picture_thumb/create.rb
Overview
Stores the render result of a Alchemy::PictureVariant in the configured Dragonfly datastore (Default: Dragonfly::FileDataStore)
Class Method Summary collapse
-
.call(variant, signature, uid) ⇒ Alchemy::PictureThumb
The persisted thumbnail record.
Class Method Details
.call(variant, signature, uid) ⇒ Alchemy::PictureThumb
Returns The persisted thumbnail record.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/alchemy/picture_thumb/create.rb', line 17 def call(variant, signature, uid) return if !variant.picture.valid? # create the thumb before storing # to prevent db race conditions thumb = Alchemy::PictureThumb.create!( picture: variant.picture, signature: signature, uid: uid, ) begin # process the image image = variant.image # store the processed image image.to_file(server_path(uid)).close rescue RuntimeError => e ErrorTracking.notification_handler.call(e) # destroy the thumb if processing or storing fails thumb&.destroy end end |