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.
Methods
Attributes
[R] | blob | |
[R] | variation |
Class Public methods
new(blob, variation)
📝 Source code
# File activestorage/app/models/active_storage/variant_with_record.rb, line 14
def initialize(blob, variation)
@blob, @variation = blob, ActiveStorage::Variation.wrap(variation)
end
🔎 See on GitHub
Instance Public methods
destroy()
Destroys record and deletes file from service.
📝 Source code
# File activestorage/app/models/active_storage/variant_with_record.rb, line 32
def destroy
record&.destroy
end
🔎 See on GitHub
filename()
📝 Source code
# File activestorage/app/models/active_storage/variant_with_record.rb, line 27
def filename
ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}"
end
🔎 See on GitHub
image()
📝 Source code
# File activestorage/app/models/active_storage/variant_with_record.rb, line 23
def image
record&.image
end
🔎 See on GitHub
processed()
📝 Source code
# File activestorage/app/models/active_storage/variant_with_record.rb, line 18
def processed
process unless processed?
self
end
🔎 See on GitHub