Methods
Public Class
Public Instance
Public Class methods
new(**args)
Inherits global hooks if defined.
[show source]
# File lib/shrine/plugins/backgrounding.rb 39 def initialize(**args) 40 super(**args) 41 @destroy_block = self.class.destroy_block 42 @promote_block = self.class.promote_block 43 end
Public Instance methods
destroy_attached()
Does a background destroy if destroy block was registered.
[show source]
# File lib/shrine/plugins/backgrounding.rb 86 def destroy_attached 87 if destroy? && destroy_block 88 destroy_background 89 else 90 super 91 end 92 end
destroy_background(**options)
Calls the registered destroy block.
[show source]
# File lib/shrine/plugins/backgrounding.rb 95 def destroy_background(**options) 96 fail Error, "destroy block is not registered" unless destroy_block 97 98 background_block(destroy_block, **options) 99 end
destroy_block(&block)
Registers an instance-level deletion hook.
attacher.destroy_block do |attacher| Attachment::DestroyJob.perform_async(attacher.data) end
[show source]
# File lib/shrine/plugins/backgrounding.rb 64 def destroy_block(&block) 65 @destroy_block = block if block 66 @destroy_block 67 end
promote_background(**options)
Calls the registered promote block.
[show source]
# File lib/shrine/plugins/backgrounding.rb 79 def promote_background(**options) 80 fail Error, "promote block is not registered" unless promote_block 81 82 background_block(promote_block, **options) 83 end
promote_block(&block)
Registers an instance-level promotion hook.
attacher.promote_block do |attacher| Attachment::PromoteJob.perform_async( attacher.record, attacher.name attacher.file_data, ) end
[show source]
# File lib/shrine/plugins/backgrounding.rb 54 def promote_block(&block) 55 @promote_block = block if block 56 @promote_block 57 end
promote_cached(**options)
Does a background promote if promote block was registered.
[show source]
# File lib/shrine/plugins/backgrounding.rb 70 def promote_cached(**options) 71 if promote? && promote_block 72 promote_background 73 else 74 super 75 end 76 end