Class: Mail::MessageIdField

Inherits:
StructuredField show all
Includes:
CommonMessageId
Defined in:
lib/mail/fields/message_id_field.rb

Constant Summary

FIELD_NAME =
'message-id'
CAPITALIZED_FIELD =
'Message-ID'

Constants included from Constants

Constants::ASTERISK, Constants::ATOM_UNSAFE, Constants::B_VALUES, Constants::CAPITAL_M, Constants::COLON, Constants::CONTROL_CHAR, Constants::CR, Constants::CRLF, Constants::CR_ENCODED, Constants::EMPTY, Constants::ENCODED_VALUE, Constants::EQUAL_LF, Constants::FIELD_BODY, Constants::FIELD_LINE, Constants::FIELD_PREFIX, Constants::FIELD_SPLIT, Constants::FULL_ENCODED_VALUE, Constants::FWS, Constants::HEADER_LINE, Constants::HEADER_SPLIT, Constants::HYPHEN, Constants::LF, Constants::LF_ENCODED, Constants::NULL_SENDER, Constants::PHRASE_UNSAFE, Constants::QP_SAFE, Constants::QP_UNSAFE, Constants::Q_VALUES, Constants::SPACE, Constants::TEXT, Constants::TOKEN_UNSAFE, Constants::UNDERSCORE, Constants::WSP

Instance Method Summary collapse

Methods included from CommonMessageId

#default, #element, #message_id, #parse

Methods inherited from StructuredField

#charset, #charset=, #default, #errors

Methods included from Utilities

#atom_safe?, #bracket, #capitalize_field, #constantize, #dasherize, #dquote, #escape_paren, #map_lines, #map_with_index, #match_to_s, #paren, #quote_atom, #quote_phrase, #quote_token, #token_safe?, #unbracket, #underscoreize, #unparen, #unquote, #uri_escape, #uri_parser, #uri_unescape

Methods included from CommonField

#default, #field_length, #name=, #responsible_for?, #value, #value=

Constructor Details

#initialize(value = nil, charset = 'utf-8') ⇒ MessageIdField

Returns a new instance of MessageIdField



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mail/fields/message_id_field.rb', line 41

def initialize(value = nil, charset = 'utf-8')
  self.charset = charset
  @uniq = 1
  if value.blank?
    self.name = CAPITALIZED_FIELD
    self.value = generate_message_id
  else
    super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
  end
  self.parse
  self

end

Instance Method Details

#decodedObject



71
72
73
# File 'lib/mail/fields/message_id_field.rb', line 71

def decoded
  do_decode
end

#encodedObject



67
68
69
# File 'lib/mail/fields/message_id_field.rb', line 67

def encoded
  do_encode(CAPITALIZED_FIELD)
end

#message_idsObject



59
60
61
# File 'lib/mail/fields/message_id_field.rb', line 59

def message_ids
  [message_id]
end

#nameObject



55
56
57
# File 'lib/mail/fields/message_id_field.rb', line 55

def name
  'Message-ID'
end

#to_sObject



63
64
65
# File 'lib/mail/fields/message_id_field.rb', line 63

def to_s
  "<#{message_id}>"
end