Class: PostageApp::Mailer::Attachments
- Defined in:
- lib/postageapp/mailer/mailer_3.rb,
lib/postageapp/mailer/mailer_4.rb
Overview
Wrapper for creating attachments Attachments sent to PostageApp are in the following format:
'filename.ext' => {
content_type: 'content/type',
content: 'base64_encoded_content'
}
Instance Method Summary collapse
- #[]=(filename, attachment) ⇒ Object
-
#initialize(message) ⇒ Attachments
constructor
A new instance of Attachments.
Methods inherited from Hash
#dig, #recursive_stringify_keys!
Constructor Details
#initialize(message) ⇒ Attachments
Returns a new instance of Attachments.
38 39 40 41 42 |
# File 'lib/postageapp/mailer/mailer_3.rb', line 38 def initialize() @_message = .arguments['attachments'] ||= { } end |
Instance Method Details
#[]=(filename, attachment) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/postageapp/mailer/mailer_3.rb', line 44 def []=(filename, ) default_content_type = MIME::Types.type_for(filename).first.content_type rescue '' case () when Hash content_type = [:content_type] || default_content_type content = Base64.encode64([:body]) else content_type = default_content_type content = Base64.encode64() end @_message.arguments['attachments'][filename] = { 'content_type' => content_type, 'content' => content } end |