class MailHandler::Models::Email

PORO for mutating email information

Attributes

bcc[R]
bounce_to[R]
cc[R]
from[R]
html[R]
reply_to[R]
subject[R]
text[R]
to[R]

Public Class Methods

new(email_hash = {}) click to toggle source
# File lib/models/email.rb, line 8
def initialize(email_hash = {})
  @from = email_hash[:from]

  @to  = email_hash[:to]
  @cc  = email_hash[:cc]
  @bcc = email_hash[:bcc]

  @subject = email_hash[:subject]
  @text    = email_hash[:text]
  @html    = email_hash[:html]

  @reply_to  = email_hash[:reply_to]
  @bounce_to = email_hash[:bounce_to]
end

Public Instance Methods

to_h() click to toggle source
# File lib/models/email.rb, line 23
def to_h
  { from: from,
    to: to,
    cc: cc,
    bcc: bcc,
    subject: subject,
    html_body: html,
    text_body: text,
    return_path: bounce_to,
    reply: reply_to }.delete_if { |_, v| v.nil? }
end
to_s() click to toggle source
# File lib/models/email.rb, line 35
def to_s
  {
    from: from,
    to: to,
    subject: subject
  }.to_s
end