Class: Hanami::Mailer::AttachmentSet Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/mailer/attachment_set.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A collection of attachments that enforces uniqueness.

Aids the preparation of a single email delivery. It is returned from DSL::Attachments#bind, containing class-level attachment definitions. Runtime attachments can be added via #concat, and the finalized array is obtained via #to_a, which raises if any filenames are duplicated.

Instance Method Summary collapse

Constructor Details

#initialize(attachments = []) ⇒ AttachmentSet

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AttachmentSet.



13
14
15
# File 'lib/hanami/mailer/attachment_set.rb', line 13

def initialize(attachments = [])
  @attachments = attachments
end

Instance Method Details

#concat(runtime_attachments) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
# File 'lib/hanami/mailer/attachment_set.rb', line 17

def concat(runtime_attachments)
  Array(runtime_attachments).each do |attachment|
    @attachments << Attachment.from(attachment)
  end

  self
end

#to_aObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
# File 'lib/hanami/mailer/attachment_set.rb', line 25

def to_a
  ensure_unique!
  @attachments.dup
end