Class: MList::Util::TMailBuilder

Inherits:
Object
  • Object
show all
Includes:
EmailHelpers, TMailReaders, TMailWriters
Defined in:
lib/mlist/util/tmail_builder.rb

Constant Summary

Constants included from EmailHelpers

EmailHelpers::AUTO_LINK_RE, EmailHelpers::BRACKETS, EmailHelpers::BRACKETS_RE, EmailHelpers::HTML_ESCAPE, EmailHelpers::REGARD_RE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TMailWriters

#bcc=, #charset, #delete_header, #from=, #headers=, #in_reply_to=, #mailer=, #message_id=, #prepend_header, #to=, #write_header

Methods included from TMailReaders

#date, #from_address, #html, #identifier, #mailer, #text, #text_html_part, #text_plain_part

Methods included from EmailHelpers

#auto_link_urls, #bracket, #escape_once, #header_sanitizer, #html_to_text, #normalize_new_lines, #remove_brackets, #remove_regard, #sanitize_header, #subscriber_name_and_address, #text_to_html, #text_to_quoted

Constructor Details

#initialize(tmail) ⇒ TMailBuilder

Returns a new instance of TMailBuilder.



11
12
13
# File 'lib/mlist/util/tmail_builder.rb', line 11

def initialize(tmail)
  @tmail = tmail
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object

Provide delegation to most of the underlying TMail::Mail methods, excluding those overridden by this Module.



32
33
34
35
36
37
38
# File 'lib/mlist/util/tmail_builder.rb', line 32

def method_missing(symbol, *args, &block) # :nodoc:
  if tmail.respond_to?(symbol)
    tmail.__send__(symbol, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#tmailObject (readonly)

Returns the value of attribute tmail.



9
10
11
# File 'lib/mlist/util/tmail_builder.rb', line 9

def tmail
  @tmail
end

Instance Method Details

#add_html_part(body) ⇒ Object



15
16
17
18
19
20
# File 'lib/mlist/util/tmail_builder.rb', line 15

def add_html_part(body)
  part = TMail::Mail.new
  part.body = normalize_new_lines(body)
  part.set_content_type('text/html')
  self.parts << part
end

#add_text_part(body) ⇒ Object



22
23
24
25
26
27
# File 'lib/mlist/util/tmail_builder.rb', line 22

def add_text_part(body)
  part = TMail::Mail.new
  part.body = normalize_new_lines(body)
  part.set_content_type('text/plain')
  self.parts << part
end