Skip to content

Instantly share code, notes, and snippets.

@asvetly
Created August 11, 2017 08:50
Show Gist options
  • Save asvetly/225f6b60de7aa2dee9aeaf457228367a to your computer and use it in GitHub Desktop.
Save asvetly/225f6b60de7aa2dee9aeaf457228367a to your computer and use it in GitHub Desktop.
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