Class: Mail::SenderField
- Inherits:
-
CommonAddressField
- Object
- CommonField
- StructuredField
- NamedStructuredField
- CommonAddressField
- Mail::SenderField
- Defined in:
- lib/mail/fields/sender_field.rb
Overview
Sender Field
The Sender field inherits sender StructuredField and handles the Sender: header field in the email.
Sending sender to a mail message will instantiate a Mail::Field object that has a SenderField as its field type. This includes all Mail::CommonAddress module instance metods.
Only one Sender field can appear in a header, though it can have multiple addresses and groups of addresses.
Examples:
mail = Mail.new
mail.sender = 'Mikel Lindsaar <[email protected]>'
mail.sender #=> '[email protected]'
mail[:sender] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::SenderField:0x180e1c4
mail['sender'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::SenderField:0x180e1c4
mail['Sender'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::SenderField:0x180e1c4
mail[:sender].encoded #=> "Sender: Mikel Lindsaar <[email protected]>\r\n"
mail[:sender].decoded #=> 'Mikel Lindsaar <[email protected]>'
mail[:sender].addresses #=> ['[email protected]']
mail[:sender].formatted #=> ['Mikel Lindsaar <[email protected]>']
Constant Summary collapse
- NAME =
:nodoc:
'Sender'
Instance Attribute Summary
Attributes inherited from CommonField
#charset, #errors, #name, #value
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from CommonAddressField
#<<, #address, #addrs, #decoded_group_addresses, #display_names, #each, #element, #encode_if_needed, #encoded_group_addresses, #formatted, #group_addresses, #group_names, #groups, #initialize
Methods inherited from NamedStructuredField
Methods inherited from CommonField
#decoded, #element, #encoded, #initialize, #parse, parse, #responsible_for?, #singular?, #to_s
Constructor Details
This class inherits a constructor from Mail::CommonAddressField
Class Method Details
.singular? ⇒ Boolean
33 34 35 |
# File 'lib/mail/fields/sender_field.rb', line 33 def self.singular? true end |
Instance Method Details
#addresses ⇒ Object
41 42 43 |
# File 'lib/mail/fields/sender_field.rb', line 41 def addresses Array(super.first) end |
#default ⇒ Object
37 38 39 |
# File 'lib/mail/fields/sender_field.rb', line 37 def default address end |