Module: ActiveStorageBlobExtension
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/active_storage_blob_extension.rb
Overview
This is included into ActiveStorage::Attachment automatically by engine.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#active_storage_extension ⇒ Object
Find or build.
- #delete ⇒ Object
- #destroy ⇒ Object
- #mark_inherited! ⇒ Object
- #mark_public! ⇒ Object
- #permission ⇒ Object
- #permission_inherited? ⇒ Boolean
- #permission_public? ⇒ Boolean
- #purge ⇒ Object
-
#purge! ⇒ Object
The purge! command is not part of the regular ActiveStorage::Blob class This is the command called by the admin/storage datatable When config.never_delete_active_storage is enabled, this is the only way to delete a Blob And they will not be deleted in the background.
- #purge_later ⇒ Object
-
#to_s ⇒ Object
Instance methods.
Instance Method Details
#active_storage_extension ⇒ Object
Find or build
26 27 28 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 26 def active_storage_extension active_storage_extensions.to_a.first || active_storage_extensions.build(permission: 'inherited') end |
#delete ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 67 def delete if EffectiveStorage.never_delete? Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob delete" return end super end |
#destroy ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 76 def destroy if EffectiveStorage.never_delete? Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob destroy" return end super end |
#mark_inherited! ⇒ Object
42 43 44 45 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 42 def mark_inherited! active_storage_extension.assign_attributes(permission: 'inherited') save! end |
#mark_public! ⇒ Object
47 48 49 50 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 47 def mark_public! active_storage_extension.assign_attributes(permission: 'public') save! end |
#permission ⇒ Object
30 31 32 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 30 def active_storage_extension. end |
#permission_inherited? ⇒ Boolean
34 35 36 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 34 def == 'inherited' end |
#permission_public? ⇒ Boolean
38 39 40 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 38 def == 'public' end |
#purge ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 85 def purge if EffectiveStorage.never_delete? Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob purge" return end super end |
#purge! ⇒ Object
The purge! command is not part of the regular ActiveStorage::Blob class This is the command called by the admin/storage datatable When config.never_delete_active_storage is enabled, this is the only way to delete a Blob And they will not be deleted in the background.
56 57 58 59 60 61 62 63 64 65 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 56 def purge! before = EffectiveStorage.never_delete begin EffectiveStorage.never_delete = false purge ensure EffectiveStorage.never_delete = before end end |
#purge_later ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 94 def purge_later if EffectiveStorage.never_delete? Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob purge_later" return end super end |
#to_s ⇒ Object
Instance methods
21 22 23 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 21 def to_s filename.presence || 'blob' end |