Guest User

Untitled

a guest
Jun 19th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. class ReportSender
  2. def initialize(data, account)
  3. @data = data
  4. @account = account
  5. @report = ''
  6. end
  7.  
  8. def generate_report!
  9. @report = @data.map { |row| "User: #{row.user} action: #{row.action} date: #{row.created_at}"
  10. }.join("\n")
  11. end
  12.  
  13. def send_report
  14. Mailer.deliver(
  15. from: 'foo@bar.com',
  16. to: @account.email,
  17. subject: 'Report',
  18. body: @report
  19. )
  20. end
  21. end
  22.  
  23. report_sender = ReportSender.new(data, account)
  24. report_sender.generate_report!
  25. report_sender.send_report
Add Comment
Please, Sign In to add comment