Method: MultiMail::Receiver::Base::ClassMethods#add_file_arguments

Defined in:
lib/multi_mail/receiver/base.rb

#add_file_arguments(attachment) ⇒ Hash

ActionDispatch::Http::Request subclasses Rack::Request and turns attachment hashes into instances of ActionDispatch::Http::UploadedFile in Rails 3 and 4 and instances of ActionController::UploadedFile in Rails 2.3, both of which have the same interface.

Parameters:

  • attachment (ActionDispatch::Http::UploadedFile, ActionController::UploadedFile, Hash)

    an attachment

Returns:

  • (Hash)

    arguments for Mail::Message#add_file



69
70
71
72
73
74
75
# File 'lib/multi_mail/receiver/base.rb', line 69

def add_file_arguments(attachment)
  if Hash === attachment
    {:filename => attachment[:filename], :content => attachment[:tempfile].read}
  else
    {:filename => attachment.original_filename, :content => attachment.read}
  end
end