class Mandrill::WebHook::Attachment

Wraps an individual (file) attachment as part of a Mandrill event payload.

Each attachment is described in the raw Mandrill payload as a hash with three elements:

'name' => the filename
'type' => the content mime type
'content' => the raw content, which will be base64-encoded if not plain text

Public Instance Methods

base64() click to toggle source

Returns a boolean for whether the attachment content is base64 encoded

# File lib/mandrill/web_hook/attachment.rb, line 28
def base64
  self['base64']
end
content() click to toggle source

Returns the raw attachment content, which may be base64 encoded

# File lib/mandrill/web_hook/attachment.rb, line 23
def content
  self['content']
end
decoded_content() click to toggle source

Returns the decoded content for the attachment

# File lib/mandrill/web_hook/attachment.rb, line 33
def decoded_content
  if base64
    Base64.decode64(content)
  else
    content
  end
rescue # any decoding error, just return the content
  content
end
name() click to toggle source

Returns the attachment name

# File lib/mandrill/web_hook/attachment.rb, line 13
def name
  self['name']
end
type() click to toggle source

Returns the attachment mime type

# File lib/mandrill/web_hook/attachment.rb, line 18
def type
  self['type']
end