module Shrine::Plugins::Backgrounding::AttacherClassMethods

Public Instance Methods

destroy_block(&block) click to toggle source

Registers a global deletion block.

Shrine::Attacher.destroy_block do |attacher|
  Attachment::DestroyJob.perform_async(attacher.data)
end
# File lib/shrine/plugins/backgrounding.rb, line 31
def destroy_block(&block)
  shrine_class.opts[:backgrounding][:destroy_block] = block if block
  shrine_class.opts[:backgrounding][:destroy_block]
end
promote_block(&block) click to toggle source

Registers a global promotion block.

Shrine::Attacher.promote_block do |attacher|
  Attachment::PromoteJob.perform_async(
    attacher.record,
    attacher.name,
    attacher.file_data,
  )
end
# File lib/shrine/plugins/backgrounding.rb, line 21
def promote_block(&block)
  shrine_class.opts[:backgrounding][:promote_block] = block if block
  shrine_class.opts[:backgrounding][:promote_block]
end