класс ActiveStorage::VariantWithRecord
Подобно ActiveStorage::Variant, но хранит подробности о варианте в базе данных как ActiveStorage::VariantRecord. Используется только при включённом `ActiveStorage.track_variants`.
Атрибуты
blob[Ч]
variation[Ч]
Публичные методы класса
# File activestorage/app/models/active_storage/variant_with_record.rb, line 9 def initialize(blob, variation) @blob, @variation = blob, ActiveStorage::Variation.wrap(variation) end
Публичные методы экземпляра
# File activestorage/app/models/active_storage/variant_with_record.rb, line 26 def image record&.image end
# File activestorage/app/models/active_storage/variant_with_record.rb, line 18
def process
transform_blob { |image| create_or_find_record(image: image) } unless processed?
end # File activestorage/app/models/active_storage/variant_with_record.rb, line 13 def processed process self end
# File activestorage/app/models/active_storage/variant_with_record.rb, line 22 def processed? record.present? end
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.