Class: MIME::Multipart::Related

Inherits:
MIME::Multipart show all
Defined in:
lib/mime/composite_media.rb

Overview

The Related subtype aggregates multiple related entities. The message consists of a root (the first entity) which references subsequent inline entities. Message entities should be referenced by their Content-ID header. The syntax of a reference is unspecified and is instead dictated by the encoding or protocol used in the entity.


RFC consulted during implementation:

  • RFC-2387 The MIME Multipart/Related Content-type

Instance Attribute Summary

Attributes inherited from CompositeMedia

#boundary

Attributes inherited from MIME::Media

#body, #headers

Attributes included from Headers::MIME

#description, #disposition, #id, #mime_version, #transfer_encoding, #type

Instance Method Summary collapse

Methods inherited from CompositeMedia

#attach, #inline

Methods inherited from MIME::Media

#to_s

Constructor Details

#initializeRelated

Returns a Multipart::Related object with a content type of multipart/related.



228
229
230
# File 'lib/mime/composite_media.rb', line 228

def initialize
  super('related')
end

Instance Method Details

#add(entity) ⇒ Object

The first entity added becomes the root object. The related message type is set to the value of the root object media type. – The “type” parameter is required and should equal the root media type. tools.ietf.org/html/rfc2387#section-3.1



239
240
241
242
243
244
245
# File 'lib/mime/composite_media.rb', line 239

def add entity
  unless type.include? '; type='
    root_type = entity.type.partition(';').first  # omit parameters
    self.type = append_field_params(type, 'type' => root_type)
  end
  super
end