Class: Griddler::Email

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper
Defined in:
lib/griddler/email.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Email

Returns a new instance of Email.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/griddler/email.rb', line 25

def initialize(params)
  @params = params

  @to = recipients(:to)
  @from = extract_address(params[:from])
  @subject = extract_subject

  @body = extract_body
  @raw_text = params[:text]
  @raw_html = params[:html]
  @raw_body = @raw_text.presence || @raw_html

  @headers = extract_headers

  @cc = recipients(:cc)
  @bcc = recipients(:bcc)
  @original_recipient = extract_address(params[:original_recipient])
  @reply_to = extract_address(params[:reply_to])

  @raw_headers = params[:headers]

  @attachments = params[:attachments]

  @vendor_specific = params.fetch(:vendor_specific, {})

  @spam_report = params[:spam_report]

  @charsets = params[:charsets]
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



7
8
9
# File 'lib/griddler/email.rb', line 7

def attachments
  @attachments
end

#bccObject (readonly)

Returns the value of attribute bcc.



7
8
9
# File 'lib/griddler/email.rb', line 7

def bcc
  @bcc
end

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/griddler/email.rb', line 7

def body
  @body
end

#ccObject (readonly)

Returns the value of attribute cc.



7
8
9
# File 'lib/griddler/email.rb', line 7

def cc
  @cc
end

#charsetsObject (readonly)

Returns the value of attribute charsets.



7
8
9
# File 'lib/griddler/email.rb', line 7

def charsets
  @charsets
end

#fromObject (readonly)

Returns the value of attribute from.



7
8
9
# File 'lib/griddler/email.rb', line 7

def from
  @from
end

#headersObject (readonly)

Returns the value of attribute headers.



7
8
9
# File 'lib/griddler/email.rb', line 7

def headers
  @headers
end

#original_recipientObject (readonly)

Returns the value of attribute original_recipient.



7
8
9
# File 'lib/griddler/email.rb', line 7

def original_recipient
  @original_recipient
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



7
8
9
# File 'lib/griddler/email.rb', line 7

def raw_body
  @raw_body
end

#raw_headersObject (readonly)

Returns the value of attribute raw_headers.



7
8
9
# File 'lib/griddler/email.rb', line 7

def raw_headers
  @raw_headers
end

#raw_htmlObject (readonly)

Returns the value of attribute raw_html.



7
8
9
# File 'lib/griddler/email.rb', line 7

def raw_html
  @raw_html
end

#raw_textObject (readonly)

Returns the value of attribute raw_text.



7
8
9
# File 'lib/griddler/email.rb', line 7

def raw_text
  @raw_text
end

#reply_toObject (readonly)

Returns the value of attribute reply_to.



7
8
9
# File 'lib/griddler/email.rb', line 7

def reply_to
  @reply_to
end

#spam_reportObject (readonly)

Returns the value of attribute spam_report.



7
8
9
# File 'lib/griddler/email.rb', line 7

def spam_report
  @spam_report
end

#subjectObject (readonly)

Returns the value of attribute subject.



7
8
9
# File 'lib/griddler/email.rb', line 7

def subject
  @subject
end

#toObject (readonly)

Returns the value of attribute to.



7
8
9
# File 'lib/griddler/email.rb', line 7

def to
  @to
end

#vendor_specificObject (readonly)

Returns the value of attribute vendor_specific.



7
8
9
# File 'lib/griddler/email.rb', line 7

def vendor_specific
  @vendor_specific
end

Instance Method Details

#spam_scoreObject



76
77
78
# File 'lib/griddler/email.rb', line 76

def spam_score
  @spam_report[:score] if @spam_report
end

#to_hObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/griddler/email.rb', line 55

def to_h
  @to_h ||= {
    to: to,
    from: from,
    cc: cc,
    bcc: bcc,
    subject: subject,
    body: body,
    raw_body: raw_body,
    raw_text: raw_text,
    raw_html: raw_html,
    headers: headers,
    raw_headers: raw_headers,
    attachments: attachments,
    vendor_specific: vendor_specific,
    spam_score: spam_score,
    spam_report: spam_report,
    charsets: charsets,
  }
end