Last active
November 29, 2020 19:57
-
-
Save asvetly/922cfb920e13fe99f3645d4b8660b51e 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(data, account) | |
@data = data | |
@account = account | |
@report = '' | |
end | |
def generate_report! | |
@report = @data.map { |row| "User: #{row.user} action: #{row.action} date: #{row.created_at}" | |
}.join("\n") | |
end | |
def send_report | |
Mailer.deliver( | |
from: 'foo@bar.com', | |
to: @account.email, | |
subject: 'Report', | |
body: @report | |
) | |
end | |
end | |
report_sender = ReportSender.new(data, account) | |
report_sender.generate_report! | |
report_sender.send_report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment