Module: Shrine::Plugins::Backgrounding::AttacherClassMethods

Defined in:
lib/shrine/plugins/backgrounding.rb

Instance Method Summary collapse

Instance Method Details

#destroy_block(&block) ⇒ Object

Registers a global deletion block.

Shrine::Attacher.destroy_block do |attacher|
  Attachment::DestroyJob.perform_async(attacher.data)
end


31
32
33
34
# 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) ⇒ Object

Registers a global promotion block.

Shrine::Attacher.promote_block do |attacher|
  Attachment::PromoteJob.perform_async(
    attacher.record,
    attacher.name,
    attacher.file_data,
  )
end


21
22
23
24
# 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