Class: Dolphin::MessageBuilder::Mail

Inherits:
Base
  • Object
show all
Defined in:
lib/dolphin/message_builder.rb

Constant Summary collapse

MESSAGE_BOUNDARY =
"----------------------------------------".freeze

Instance Method Summary collapse

Methods inherited from Base

#build_message, #initialize

Methods included from Util

#logger

Constructor Details

This class inherits a constructor from Dolphin::MessageBuilder::Base

Instance Method Details

#build(template_id, params) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/dolphin/message_builder.rb', line 62

def build(template_id, params)
  message = ''

  if template_id.blank?
    template_id = 'default'
  end

  body_template = template(template_id)
  if body_template.nil?
    return nil
  end

  message = build_message(body_template, params['messages'])
  subject, body = message.split(MESSAGE_BOUNDARY)
  subject.strip! unless subject.nil?
  body.strip! unless body.nil?

  notification = NotificationObject.new
  notification.subject = subject
  notification.from = Dolphin.settings['mail']['from']
  notification.to = params["to"]
  notification.cc ||= params["cc"]
  notification.bcc ||= params["bcc"]
  notification.body = body
  notification
end