Last active
August 11, 2017 10:49
-
-
Save asvetly/df5f9257507f6cbbcd281a0d548d2512 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 | |
Mailer.deliver( | |
from: 'foo@bar.com', | |
to: @account.email, | |
subject: 'Report', | |
body: @report | |
) | |
end | |
end | |
class ReportGenerator | |
def initialize(data) | |
@data = data | |
end | |
def generate | |
@data.map { |row| "User: #{row.user} action: #{row.action} date: #{row.created_at}" | |
}.join("\n") | |
end | |
end | |
report = ReportGenerator.new(data).generate | |
ReportSender.new(report, account).send_report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment