Skip to content

Instantly share code, notes, and snippets.

@jasdeepsingh
Created September 21, 2014 22:29
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 jasdeepsingh/d9d21a20e0a4cc0eda7a to your computer and use it in GitHub Desktop.
Save jasdeepsingh/d9d21a20e0a4cc0eda7a to your computer and use it in GitHub Desktop.
notifier_proxy.rb
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