Class: Alchemy::PictureThumb::Create
- Inherits:
-
Object
- Object
- Alchemy::PictureThumb::Create
- Defined in:
- app/models/alchemy/picture_thumb/create.rb
Overview
Creates a Alchemy::PictureThumb
Stores the processes result of a Alchemy::PictureVariant in the configured Alchemy::PictureThumb.storage_class
(Default: FileStore)
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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/alchemy/picture_thumb/create.rb', line 19 def call(variant, signature, uid) return if !variant.picture.valid? # create the thumb before storing # to prevent db race conditions @thumb = Alchemy::PictureThumb.create_or_find_by!(signature: signature) do |thumb| thumb.picture = variant.picture thumb.uid = uid end begin Alchemy::PictureThumb.storage_class.call(variant, uid) rescue => e ErrorTracking.notification_handler.call(e) # destroy the thumb if processing or storing fails @thumb&.destroy end end |