module Shrine::Plugins::Backgrounding::AttacherMethods
Public Class Methods
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
Inherits global hooks if defined.
Calls superclass method
Public Instance Methods
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
Does a background destroy if destroy block was registered.
Calls superclass method
Source
# File lib/shrine/plugins/backgrounding.rb 95 def destroy_background(**) 96 fail Error, "destroy block is not registered" unless destroy_block 97 98 background_block(destroy_block, **) 99 end
Calls the registered destroy block.
Source
# File lib/shrine/plugins/backgrounding.rb 64 def destroy_block(&block) 65 @destroy_block = block if block 66 @destroy_block 67 end
Registers an instance-level deletion hook.
attacher.destroy_block do |attacher| Attachment::DestroyJob.perform_async(attacher.data) end
Source
# File lib/shrine/plugins/backgrounding.rb 79 def promote_background(**) 80 fail Error, "promote block is not registered" unless promote_block 81 82 background_block(promote_block, **) 83 end
Calls the registered promote block.
Source
# File lib/shrine/plugins/backgrounding.rb 54 def promote_block(&block) 55 @promote_block = block if block 56 @promote_block 57 end
Registers an instance-level promotion hook.
attacher.promote_block do |attacher| Attachment::PromoteJob.perform_async( attacher.record, attacher.name, attacher.file_data, ) end
Source
# File lib/shrine/plugins/backgrounding.rb 70 def promote_cached(**) 71 if promote? && promote_block 72 promote_background(**) 73 else 74 super 75 end 76 end
Does a background promote if promote block was registered.
Calls superclass method