Created
August 11, 2017 08:50
-
-
Save asvetly/225f6b60de7aa2dee9aeaf457228367a 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 ReportSender | |
def initialize(report, account) | |
@report = report | |
@account = account | |
end | |
def send_report(sender = EmailSender.new) | |
sender.send(@account) | |
end | |
end | |
class ReportGenerator | |
# report generation | |
end | |
class Sender | |
def send(account) | |
raise NotImplementedError | |
end | |
end | |
class EmailSender < Sender | |
def send(account) | |
# implementation for Email | |
end | |
end | |
class SmsSender < Sender | |
def send(account) | |
# implementation for SMS | |
end | |
end | |
report = ReportGenerator.new(data).generate | |
ReportSender.new(report, account).send_report(SmsSender.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment