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
24 25 26 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 24 def active_storage_extension active_storage_extensions.to_a.first || active_storage_extensions.build(permission: 'inherited') end |
#delete ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 65 def delete if EffectiveStorage.never_delete? Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob delete" return end super end |
#destroy ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 74 def destroy if EffectiveStorage.never_delete? Rails.logger.info "[effective_storage] Skipping ActiveStorage::Blob destroy" return end super end |
#mark_inherited! ⇒ Object
40 41 42 43 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 40 def mark_inherited! active_storage_extension.assign_attributes(permission: 'inherited') save! end |
#mark_public! ⇒ Object
45 46 47 48 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 45 def mark_public! active_storage_extension.assign_attributes(permission: 'public') save! end |
#permission ⇒ Object
28 29 30 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 28 def active_storage_extension. end |
#permission_inherited? ⇒ Boolean
32 33 34 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 32 def == 'inherited' end |
#permission_public? ⇒ Boolean
36 37 38 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 36 def == 'public' end |
#purge ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 83 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.
54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 54 def purge! before = EffectiveStorage.never_delete begin EffectiveStorage.never_delete = false purge ensure EffectiveStorage.never_delete = before end end |
#purge_later ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 92 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
19 20 21 |
# File 'app/models/concerns/active_storage_blob_extension.rb', line 19 def to_s filename.presence || 'blob' end |