Class: Mail::MessageIdField

Inherits:
CommonMessageIdField show all
Defined in:
lib/mail/fields/message_id_field.rb

Overview

Only one Message-ID field may appear in a header.

Note that parsed Message IDs do not contain their enclosing angle brackets which, per RFC, are not part of the ID.

mail = Mail.new
mail.message_id = '<[email protected]>'
mail.message_id    #=> '<[email protected]>'
mail[:message_id]  #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::MessageIdField:0x180e1c4
mail['message_id'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::MessageIdField:0x180e1c4
mail['Message-ID'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::MessageIdField:0x180e1c4

mail[:message_id].message_id   #=> '[email protected]'
mail[:message_id].message_ids  #=> ['[email protected]']

Constant Summary collapse

NAME =

:nodoc:

'Message-ID'

Instance Attribute Summary

Attributes inherited from CommonField

#charset, #errors, #name, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommonMessageIdField

#default, #element, #message_id, #to_s

Methods inherited from CommonField

#decoded, #default, #element, #encoded, #parse, parse, #responsible_for?, #singular?, #to_s

Constructor Details

#initialize(value = nil, charset = nil) ⇒ MessageIdField

Returns a new instance of MessageIdField.



28
29
30
31
# File 'lib/mail/fields/message_id_field.rb', line 28

def initialize(value = nil, charset = nil)
  value = Mail::Utilities.generate_message_id if Utilities.blank?(value)
  super value, charset
end

Class Method Details

.singular?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/mail/fields/message_id_field.rb', line 24

def self.singular?
  true
end

Instance Method Details

#message_idsObject



33
34
35
# File 'lib/mail/fields/message_id_field.rb', line 33

def message_ids
  [message_id]
end