Class: ChangeManager::NotificationMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/change_manager/notification_mailer.rb

Instance Method Summary collapse

Instance Method Details

#construct_email(changes) ⇒ Object



6
7
8
9
10
11
12
13
# File 'app/mailers/change_manager/notification_mailer.rb', line 6

def construct_email(changes)
	@body = prepare_body(changes)
	mail(
		to: changes.first.target,
		from: changes.first.owner,
		subject: 'Recent Updates from ' + CONFIG['site_name'],
		)
end

#prepare_body(changes) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/mailers/change_manager/notification_mailer.rb', line 19

def prepare_body(changes)
	header = '<table><th><td>Change Owner</td><td>Change Context</td><td>Change</td><td>Time</td></th>'
	body = ''
	footer = '</table>'
	changes.each do |change|
		body += '<tr><td>' + 
		change.owner + '</td><td>' + 
		change.context + '</td><td>' + 
		change.change_type + '</td><td>' + 
		change.created_at.to_s + '</td></tr>'
	end
	content = header + body + footer
end

#send_email(constructed_email) ⇒ Object



15
16
17
# File 'app/mailers/change_manager/notification_mailer.rb', line 15

def send_email(constructed_email)
	constructed_email.deliver
end