Class: MailHandler::Models::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/models/email.rb

Overview

PORO for mutating email information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email_hash = {}) ⇒ Email

Returns a new instance of Email.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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

Instance Attribute Details

#bccObject (readonly)

Returns the value of attribute bcc.



5
6
7
# File 'lib/models/email.rb', line 5

def bcc
  @bcc
end

#bounce_toObject (readonly)

Returns the value of attribute bounce_to.



5
6
7
# File 'lib/models/email.rb', line 5

def bounce_to
  @bounce_to
end

#ccObject (readonly)

Returns the value of attribute cc.



5
6
7
# File 'lib/models/email.rb', line 5

def cc
  @cc
end

#fromObject (readonly)

Returns the value of attribute from.



5
6
7
# File 'lib/models/email.rb', line 5

def from
  @from
end

#htmlObject (readonly)

Returns the value of attribute html.



5
6
7
# File 'lib/models/email.rb', line 5

def html
  @html
end

#reply_toObject (readonly)

Returns the value of attribute reply_to.



5
6
7
# File 'lib/models/email.rb', line 5

def reply_to
  @reply_to
end

#subjectObject (readonly)

Returns the value of attribute subject.



5
6
7
# File 'lib/models/email.rb', line 5

def subject
  @subject
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/models/email.rb', line 5

def text
  @text
end

#toObject (readonly)

Returns the value of attribute to.



5
6
7
# File 'lib/models/email.rb', line 5

def to
  @to
end

Instance Method Details

#to_hObject



23
24
25
26
27
28
29
30
31
32
33
# 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_sObject



35
36
37
38
39
40
41
# File 'lib/models/email.rb', line 35

def to_s
  {
    from: from,
    to: to,
    subject: subject
  }.to_s
end