Class: Mandrill::WebHook::Attachment
- Inherits:
-
Hash
- Object
- Hash
- Mandrill::WebHook::Attachment
- Defined in:
- lib/mandrill/web_hook/attachment.rb
Overview
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
Instance Method Summary collapse
-
#content ⇒ Object
Returns the raw attachment content, which may be base64 encoded if not plain text.
-
#decoded_content ⇒ Object
Returns the decoded content for the attachment.
-
#name ⇒ Object
Returns the attachment name.
-
#type ⇒ Object
Returns the attachment mime type.
Instance Method Details
#content ⇒ Object
Returns the raw attachment content, which may be base64 encoded if not plain text
23 24 25 |
# File 'lib/mandrill/web_hook/attachment.rb', line 23 def content self['content'] end |
#decoded_content ⇒ Object
Returns the decoded content for the attachment
28 29 30 31 32 33 34 35 36 |
# File 'lib/mandrill/web_hook/attachment.rb', line 28 def decoded_content if type =~ /^text/ content else # assume it is base64-encoded Base64.decode64(content) end rescue # any decoding error, just return the content content end |
#name ⇒ Object
Returns the attachment name
13 14 15 |
# File 'lib/mandrill/web_hook/attachment.rb', line 13 def name self['name'] end |
#type ⇒ Object
Returns the attachment mime type
18 19 20 |
# File 'lib/mandrill/web_hook/attachment.rb', line 18 def type self['type'] end |