Module: NotifyOn::EmailSupport
- Included in:
- Notification
- Defined in:
- app/models/concerns/notify_on/email_support.rb
Instance Method Summary collapse
- #email_attachments ⇒ Object
- #email_from ⇒ Object
- #email_reply_to ⇒ Object
- #email_subject ⇒ Object
- #email_template ⇒ Object
- #send_email! ⇒ Object
- #should_save_email_id? ⇒ Boolean
Instance Method Details
#email_attachments ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/concerns/notify_on/email_support.rb', line 38 def = [] return unless email_config? && email_config. email_config..each do |name, renderer| next unless trigger.send(renderer.if) if renderer.try(:if?) filename = begin trigger.send(name) rescue => e name end begin file = if renderer.is_a?(Symbol) trigger.send(renderer) else trigger.send(renderer.file) end rescue => e raise "Could not create file: #{filename}\n#{e}" end << { :name => filename, :file => file } end end |
#email_from ⇒ Object
20 21 22 |
# File 'app/models/concerns/notify_on/email_support.rb', line 20 def email_from convert_string(email_from_raw) end |
#email_reply_to ⇒ Object
24 25 26 |
# File 'app/models/concerns/notify_on/email_support.rb', line 24 def email_reply_to convert_string(email_config.reply_to) if email_config.reply_to? end |
#email_subject ⇒ Object
28 29 30 31 |
# File 'app/models/concerns/notify_on/email_support.rb', line 28 def email_subject return email_config.subject if email_config? && email_config.subject? description end |
#email_template ⇒ Object
15 16 17 18 |
# File 'app/models/concerns/notify_on/email_support.rb', line 15 def email_template return nil unless email_config? email_config.template || 'notify' end |
#send_email! ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'app/models/concerns/notify_on/email_support.rb', line 4 def send_email! return false unless can_send_email? begin NotifyOn.configuration.mailer_class.constantize .notify(id, email_template, ) .send("deliver_#{email_delivery_timing}") rescue Exception => e Rails.logger.error("Unable to send notification email: #{e}") end end |
#should_save_email_id? ⇒ Boolean
33 34 35 36 |
# File 'app/models/concerns/notify_on/email_support.rb', line 33 def should_save_email_id? # if we are using postmark and have callbacks for read receipts, we need this to default to true... email_config? && email_config.save_id? end |