Active Storage Variant With Record
像是 ActiveStorage::Variant
,會將變異的詳細資訊儲存在資料庫中,做為 ActiveStorage::VariantRecord
。此功能僅在啟用 ActiveStorage.track_variants
時才會使用。
方法
屬性
[R] | blob | |
[R] | variation |
類別公開方法
new(blob, variation) 連結
來源: 顯示 | 在 GitHub 上
# File activestorage/app/models/active_storage/variant_with_record.rb, line 14 def initialize(blob, variation) @blob, @variation = blob, ActiveStorage::Variation.wrap(variation) end
執行個體公開方法
destroy() 連結
銷毀紀錄並從服務中刪除檔案。
來源: 顯示 | 在 GitHub 上
# File activestorage/app/models/active_storage/variant_with_record.rb, line 32 def destroy record&.destroy end
filename() 連結
來源: 顯示 | 在 GitHub 上
# File activestorage/app/models/active_storage/variant_with_record.rb, line 27 def filename ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}" end
image() 連結
來源: 顯示 | 在 GitHub 上
# File activestorage/app/models/active_storage/variant_with_record.rb, line 23 def image record&.image end
processed() 連結
來源: 顯示 | 在 GitHub 上
# File activestorage/app/models/active_storage/variant_with_record.rb, line 18 def processed process unless processed? self end