Created
May 12, 2017 11:35
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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