Class: MultiMail::Message::Base

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/multi_mail/message/base.rb

Direct Known Subclasses

Cloudmailin, Mailgun, Mandrill, Postmark, SendGrid

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Base

Returns a new instance of Base.



4
5
6
7
8
9
10
# File 'lib/multi_mail/message/base.rb', line 4

def initialize(*args, &block)
  if args.empty?
    __setobj__(Mail::Message.new(&block))
  else
    super
  end
end

Instance Method Details

#body_htmlObject



17
18
19
20
21
22
23
# File 'lib/multi_mail/message/base.rb', line 17

def body_html
  if html_part
    html_part.body.decoded
  elsif html?
    body.decoded
  end
end

#body_textObject



25
26
27
28
29
30
31
# File 'lib/multi_mail/message/base.rb', line 25

def body_text
  if text_part
    text_part.body.decoded
  elsif !html?
    body.decoded
  end
end

#html?Boolean



13
14
15
# File 'lib/multi_mail/message/base.rb', line 13

def html?
  !!content_type && content_type.include?('text/html')
end

#tagsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/multi_mail/message/base.rb', line 33

def tags
  if self['tag']
    if self['tag'].respond_to?(:map)
      self['tag'].map do |field|
        field.value
      end
    else
      [self['tag'].value]
    end
  else
    []
  end
end