Module: Alchemy::StorageAdapter::ActiveStorage::AttachmentClassMethods
- Defined in:
- app/models/alchemy/storage_adapter/active_storage.rb
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/alchemy/storage_adapter/active_storage.rb', line 29 def self.included(base) base.has_one_attached :file base.after_create_commit if: :svg? do SanitizeSvgJob.perform_later(self, file_accessor: :file) end # The file's dirty state is cleared by the time # +after_update_commit+ runs, so capture it here to know whether the # blob was actually replaced (rather than only its metadata updated). base.before_update do @file_replaced = file.changed? end base.after_update_commit if: -> { @file_replaced && svg? } do SanitizeSvgJob.perform_later(self, file_accessor: :file) end end |