Created
September 21, 2014 22:29
-
-
Save jasdeepsingh/d9d21a20e0a4cc0eda7a to your computer and use it in GitHub Desktop.
notifier_proxy.rb
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 Notifier | |
def notify(user) | |
if user.student? | |
send_sms(user.number) | |
elsif user.parent? | |
send_email(user.email) | |
end | |
end | |
def send_sms(number) | |
# this method encapsulates the logic | |
# that sends the sms using your 3rd party service | |
# ex: Twilio.send_sms(number) #hypothetical code | |
end | |
def send_email(email_address) | |
# this method encapsulates the logic | |
# that sends the email using your 3rd party service | |
# ex: SendGrid.send_email(email) #hypothetical code | |
end | |
end | |
notifier = Notifier.new | |
parent = Parent.find_from_database('email_of_parent@gmail.com') | |
student = Student.find_from_database('919814911789') | |
notifier.notify(student) | |
notifier.notify(parent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment