跳至內容 跳至搜尋

Active Storage Variant With Record

像是 ActiveStorage::Variant,會將變異的詳細資訊儲存在資料庫中,做為 ActiveStorage::VariantRecord。此功能僅在啟用 ActiveStorage.track_variants 時才會使用。

方法
D
F
I
N
P

屬性

[R] blob
[R] variation

類別公開方法

new(blob, variation)

# 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()

銷毀紀錄並從服務中刪除檔案。

# File activestorage/app/models/active_storage/variant_with_record.rb, line 32
def destroy
  record&.destroy
end

filename()

# 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()

# File activestorage/app/models/active_storage/variant_with_record.rb, line 23
def image
  record&.image
end

processed()

# File activestorage/app/models/active_storage/variant_with_record.rb, line 18
def processed
  process unless processed?
  self
end