Sha256: 2e767c59b41661ae5ca88fa7cbe580f85fff224c5f85ffc85e9f319943600021

Contents?: true

Size: 1.77 KB

Versions: 15

Compression:

Stored size: 1.77 KB

Contents

# encoding: utf-8
# 
# = Resent-Sender Field
# 
# The Resent-Sender field inherits resent-sender StructuredField and handles the Resent-Sender: header
# field in the email.
# 
# Sending resent_sender to a mail message will instantiate a Mail::Field object that
# has a ResentSenderField as it's field type.  This includes all Mail::CommonAddress
# module instance metods.
# 
# Only one Resent-Sender field can appear in a header, though it can have multiple
# addresses and groups of addresses.
# 
# == Examples:
# 
#  mail = Mail.new
#  mail.resent_sender = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
#  mail.resent_sender    #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentSenderField:0x180e1c4
#  mail[:resent_sender]  #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentSenderField:0x180e1c4
#  mail['resent-sender'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentSenderField:0x180e1c4
#  mail['Resent-Sender'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ResentSenderField:0x180e1c4
# 
#  mail.resent_sender.to_s  #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
#  mail.resent_sender.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
#  mail.resent_sender.formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
# 
module Mail
  class ResentSenderField < StructuredField
    
    include Mail::CommonAddress
    
    FIELD_NAME = 'resent-sender'
    CAPITALIZED_FIELD = 'Resent-Sender'

    def initialize(*args)
      super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
    end

    def addresses
      [address]
    end

    def address
      result = tree.addresses.first
    end
    
    def encoded
      do_encode(CAPITALIZED_FIELD)
    end
    
    def decoded
      do_decode
    end
    
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mail-1.4.3 lib/mail/fields/resent_sender_field.rb
mail-1.4.2 lib/mail/fields/resent_sender_field.rb
mail-1.4.1 lib/mail/fields/resent_sender_field.rb
mail-1.4.0 lib/mail/fields/resent_sender_field.rb
mail-1.3.5 lib/mail/fields/resent_sender_field.rb
mail-1.3.4 lib/mail/fields/resent_sender_field.rb
mail-1.3.3 lib/mail/fields/resent_sender_field.rb
mail-1.3.2 lib/mail/fields/resent_sender_field.rb
mail-1.3.1 lib/mail/fields/resent_sender_field.rb
mail-1.3.0 lib/mail/fields/resent_sender_field.rb
mail-1.2.9 lib/mail/fields/resent_sender_field.rb
mail-1.2.8 lib/mail/fields/resent_sender_field.rb
mail-1.2.6 lib/mail/fields/resent_sender_field.rb
mail-1.2.5 ./lib/mail/fields/resent_sender_field.rb
mail-1.2.1 ./lib/mail/fields/resent_sender_field.rb