Skip to content

Instantly share code, notes, and snippets.

@kinnrot
Created May 12, 2017 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinnrot/402fef99236ecf2599be9f8404a7799f to your computer and use it in GitHub Desktop.
Save kinnrot/402fef99236ecf2599be9f8404a7799f to your computer and use it in GitHub Desktop.
encapsulate sucker punch queueing to act same as delayed job or any other async task runner
class InProcessJob
unless Rails.env.test?
include SuckerPunch::Job
workers 1
end
include Job::Deserializers
include Job::Serializers
def self.queue_as(_)
end
def self.perform_later(*args)
if Rails.env.test?
return self.perform_now(*args)
end
self.perform_async(*args)
end
def self.perform_now(*args)
instance = self.new
instance.perform(*args)
instance
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment