Method: Mailgun::MessageBuilder#add_attachment

Defined in:
lib/mailgun/messages/message_builder.rb

#add_attachment(attachment, filename = nil) ⇒ void

This method returns an undefined value.

Adds a series of attachments, when called upon.



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/mailgun/messages/message_builder.rb', line 92

def add_attachment(attachment, filename=nil)
  if attachment.is_a?(String)
    attachment = File.open(attachment, "r")
  end
  if !attachment.is_a?(File) || !attachment.respond_to?(:read)
    raise ParameterError.new("Unable to access attachment file object.")
  end
  if !filename.nil?
    attachment.instance_eval "def original_filename; '#{filename}'; end"
  end
  complex_setter(:attachment, attachment)
end