Module: Itext::Attachments

Included in:
Itext
Defined in:
lib/itext/attachments.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
14
# File 'lib/itext/attachments.rb', line 11

def self.included(base)
  base.extend(ClassMethods)
  attr_reader :attachments
end

Instance Method Details

#add_attachments(attachments) ⇒ Object Also known as: add_attachment



16
17
18
19
20
21
22
23
# File 'lib/itext/attachments.rb', line 16

def add_attachments(attachments)
  @attachments ||= []
  attachments = [attachments] unless attachments.is_a?(Array)
  attachments.each do |attachment|
    @attachments << attachment
  end
  @attachments
end

#initialize(*args, &block) ⇒ Object



4
5
6
7
8
9
# File 'lib/itext/attachments.rb', line 4

def initialize(*args, &block)
  @hooks     ||= []
  @hooks.push ->{ process_attachments }

  super rescue nil
end

#remove_attachments(attachments) ⇒ Object Also known as: remove_attachment



27
28
29
30
31
32
33
34
# File 'lib/itext/attachments.rb', line 27

def remove_attachments(attachments)
  @attachments ||= []
  attachments = [attachments] unless attachments.is_a?(Array)
  attachments.each do |attachment|
    @attachments.delete(attachment)
  end
  @attachments
end