Skip to content

Instantly share code, notes, and snippets.

@yfkhar
Forked from simoleone/shrine.rb
Created July 25, 2019 01:05
Show Gist options
  • Save yfkhar/4b44ed4b12be7a077f17aa99448da70f to your computer and use it in GitHub Desktop.
Save yfkhar/4b44ed4b12be7a077f17aa99448da70f to your computer and use it in GitHub Desktop.
Async image processing in Shrine
Shrine.plugin :backgrounding
Shrine::Attacher.promote { |data| ShrinePromoteWorker.perform_async(data) }
Shrine::Attacher.delete { |data| ShrineDeleteWorker.perform_async(data) }
class ShrineDeleteWorker < ApplicationWorker
def perform(data)
Shrine::Attacher.delete(data)
end
end
class ShrinePromoteWorker < ApplicationWorker
def perform(data)
Shrine::Attacher.promote(data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment