Skip to content

Instantly share code, notes, and snippets.

@ejlangev
Created March 26, 2014 22:04
Show Gist options
  • Save ejlangev/9794643 to your computer and use it in GitHub Desktop.
Save ejlangev/9794643 to your computer and use it in GitHub Desktop.
class Postman
include Interactor
def perform
if should_send_push_notification?
Postman::SendPushNotification.perform(context)
else
Postman::SendTextMessage.perform(context)
end
end
private
def should_send_push_notification?
...Logic for if this should be a push notification...
end
end
class Postman::SendPushNotification
include Organizer
# Message summary is not dependent on type of message, neither is enqueu_message_job per se
# message just needs a little bit of state based on what type of message it is which is only
# a small issue in my view
organizes [:create_push_notification_log, :create_message_summary, :enqueue_message_job]
def setup
...Logic for if we can send push notifications...
end
end
class Postman::SendPushNotification
include Organizer
organizes [:create_sms_log, :create_message_summary, :enqueue_message_job]
def setup
...Logic for if we can send text messages...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment