Created
January 24, 2021 16:48
-
-
Save lolaodelola/ed56e69da2fd15f46c040edf1f48a9cc to your computer and use it in GitHub Desktop.
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 SendAffirmationJob < ApplicationJob | |
queue_as :default | |
def deliver(dev, affirmation) | |
Rails.env != 'test' ? send_prod(dev, affirmation) : send_test(dev, affirmation) | |
end | |
handle_asynchronously :deliver | |
def send_prod(dev, affirmation) | |
AffirmationText.new.message(dev.phone_number, affirmation.body) | |
end | |
def send_test(dev, affirmation) | |
MockAffirmationText.new.message(dev.phone_number, affirmation.body) | |
end | |
end | |
class MockAffirmationText | |
def message(dev_phone_number, affirmation) | |
"#{affirmation} was sent to #{dev_phone_number}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment