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
Direct Known Subclasses
Instance Method Summary collapse
-
#base64 ⇒ Object
Returns a boolean for whether the attachment content is base64 encoded.
-
#content ⇒ Object
Returns the raw attachment content, which may be base64 encoded.
-
#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
permalink #base64 ⇒ Object
Returns a boolean for whether the attachment content is base64 encoded
28 29 30 |
# File 'lib/mandrill/web_hook/attachment.rb', line 28 def base64 self['base64'] end |
permalink #content ⇒ Object
Returns the raw attachment content, which may be base64 encoded
23 24 25 |
# File 'lib/mandrill/web_hook/attachment.rb', line 23 def content self['content'] end |
permalink #decoded_content ⇒ Object
Returns the decoded content for the attachment
33 34 35 36 37 38 39 40 41 |
# 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 |
permalink #name ⇒ Object
Returns the attachment name
13 14 15 |
# File 'lib/mandrill/web_hook/attachment.rb', line 13 def name self['name'] end |
permalink #type ⇒ Object
Returns the attachment mime type
18 19 20 |
# File 'lib/mandrill/web_hook/attachment.rb', line 18 def type self['type'] end |