Sha256: fb166ca58fcc71f909cdb6af1660232d3af826640e8b0c68f744109a8f709d51
Contents?: true
Size: 1.3 KB
Versions: 52
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Alchemy class PictureThumb < BaseRecord # Creates a Alchemy::PictureThumb # # Stores the processes result of a Alchemy::PictureVariant # in the configured +Alchemy::PictureThumb.storage_class+ # (Default: {Alchemy::PictureThumb::FileStore}) # class Create class << self # @param [Alchemy::PictureVariant] variant the to be rendered image # @param [String] signature A unique hashed version of the rendering options # @param [String] uid The Unique Image Identifier the image is stored at # # @return [Alchemy::PictureThumb] The persisted thumbnail record # 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 end end end end
Version data entries
52 entries across 52 versions & 1 rubygems