class ActiveStorage::VariantWithRecord
Active Storage Variant With Record
Like an ActiveStorage::Variant
, but keeps detail about the variant in the database as an ActiveStorage::VariantRecord
. This is only used if ActiveStorage.track_variants
is enabled.
Attributes
[R] | blob |
|
[R] | variation |
Public class methods
Source code 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
Public instance methods
Destroys record and deletes file from service.
Source code GitHub
# File activestorage/app/models/active_storage/variant_with_record.rb, line 32
def destroy
record&.destroy
end
Source code 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
Source code GitHub
# File activestorage/app/models/active_storage/variant_with_record.rb, line 23
def image
record&.image
end
Source code GitHub
# File activestorage/app/models/active_storage/variant_with_record.rb, line 18
def processed
process unless processed?
self
end