Module: TMail::StrategyInterface

Included in:
Address, AddressGroup, HeaderField, Mail
Defined in:
lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_dest(obj) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb', line 46

def create_dest( obj )
  case obj
  when nil
    StringOutput.new
  when String
    StringOutput.new(obj)
  when IO, StringOutput
    obj
  else
    raise TypeError, 'cannot handle this type of object for dest'
  end
end

Instance Method Details

#accept_strategy(klass, eol, charset, dest = nil) ⇒ Object

:nodoc:



96
97
98
99
100
# File 'lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb', line 96

def accept_strategy( klass, eol, charset, dest = nil ) #:nodoc:
  dest ||= ''
  accept klass.new( create_dest(dest), charset, eol )
  dest
end

#decoded(eol = "\n", charset = 'e', dest = nil) ⇒ Object Also known as: to_s

Returns the TMail object decoded and ready to be used by you, your program etc.

You should call this before you are packaging up your email to correctly escape all the values that need escaping in the email, line wrap the email etc.

For Example:

email = TMail::Load(my_email_file)
email_to_send = email.encoded


88
89
90
91
92
# File 'lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb', line 88

def decoded( eol = "\n", charset = 'e', dest = nil )
  # Turn the E-Mail into a string and return it with all
  # encoded characters decoded.  alias for to_s
  accept_strategy Decoder, eol, charset, dest
end

#encoded(eol = "\r\n", charset = 'j', dest = nil) ⇒ Object

:startdoc: Returns the TMail object encoded and ready to be sent via SMTP etc. You should call this before you are packaging up your email to correctly escape all the values that need escaping in the email, line wrap the email etc.

It is also a good idea to call this before you marshal or serialize a TMail object.

For Example:

email = TMail::Load(my_email_file)
email_to_send = email.encoded


73
74
75
# File 'lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb', line 73

def encoded( eol = "\r\n", charset = 'j', dest = nil )
  accept_strategy Encoder, eol, charset, dest
end