Class: Fiddler::AttachmentCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/fiddler/attachment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fill(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fiddler/attachment.rb', line 12

def self.fill(*args)
   AttachmentCollection.new Array(args.compact).flatten.map { |attachment|
      if attachment.is_a?(File)
         AttachmentFile.new(attachment.path)
      elsif attachment.is_a?(String)
         AttachmentFile.new(attachment)
      elsif attachment.is_a?(ActionDispatch::Http::UploadedFile)
         AttachmentFile.new(attachment.tempfile.path, attachment.original_filename)
      end
   }.compact
end

Instance Method Details

#to_payloadObject



4
5
6
7
8
9
10
# File 'lib/fiddler/attachment.rb', line 4

def to_payload
   hash = Hash.new
   self.each_with_index do |attach, index|
      hash["attachment_#{index+1}"] = attach
   end
   hash
end