Module: ActiveStorage::AsyncVariants::PreviewExtension
- Defined in:
- lib/active_storage/async_variants/preview_extension.rb
Instance Method Summary collapse
- #async_state ⇒ Object
- #key ⇒ Object
-
#processed ⇒ Object
Enqueue (or no-op if already done) the same ProcessJob the VariantWithRecord path uses, so Preview-side and VariantWithRecord-side processing converge on a single record-and-job machinery rather than the gem’s earlier two-path design (one writing to preview_image’s variant_records, one to the original blob’s).
- #processed? ⇒ Boolean
- #url ⇒ Object
Instance Method Details
#async_state ⇒ Object
41 42 43 44 |
# File 'lib/active_storage/async_variants/preview_extension.rb', line 41 def async_state return nil unless async_preview? find_preview_variant_record&.state || "pending" end |
#key ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/active_storage/async_variants/preview_extension.rb', line 32 def key if async_preview? raise ActiveStorage::Preview::UnprocessedError unless preview_variant_processed? find_preview_variant_record.image.blob.key else super end end |
#processed ⇒ Object
Enqueue (or no-op if already done) the same ProcessJob the VariantWithRecord path uses, so Preview-side and VariantWithRecord-side processing converge on a single record-and-job machinery rather than the gem’s earlier two-path design (one writing to preview_image’s variant_records, one to the original blob’s).
11 12 13 14 15 16 17 18 |
# File 'lib/active_storage/async_variants/preview_extension.rb', line 11 def processed if async_preview? enqueue_async_preview unless preview_variant_processed? self else super end end |
#processed? ⇒ Boolean
20 21 22 |
# File 'lib/active_storage/async_variants/preview_extension.rb', line 20 def processed? async_preview? ? preview_variant_processed? : super end |
#url ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/active_storage/async_variants/preview_extension.rb', line 24 def url(...) if async_preview? preview_variant_processed? ? find_preview_variant_record.image.url(...) : fallback_preview_url(...) else super end end |