Module: Dolly::Attachment
- Included in:
- Document
- Defined in:
- lib/dolly/attachment.rb
Instance Method Summary collapse
- #attach_file(file_name, mime_type, body, opts = {}) ⇒ Object
- #attach_file!(file_name, mime_type, body, opts = {}) ⇒ Object
- #attach_inline_file(file_name, mime_type, body) ⇒ Object
- #attach_standalone_file(file_name, mime_type, body) ⇒ Object
Instance Method Details
#attach_file(file_name, mime_type, body, opts = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/dolly/attachment.rb', line 10 def attach_file file_name, mime_type, body, opts={} if opts[:inline] attach_inline_file file_name, mime_type, body else attach_standalone_file file_name, mime_type, body end end |
#attach_file!(file_name, mime_type, body, opts = {}) ⇒ Object
5 6 7 8 |
# File 'lib/dolly/attachment.rb', line 5 def attach_file! file_name, mime_type, body, opts={} attach_file file_name, mime_type, body, opts save end |
#attach_inline_file(file_name, mime_type, body) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/dolly/attachment.rb', line 18 def attach_inline_file file_name, mime_type, body = { file_name.to_s => { 'content_type' => mime_type, 'data' => Base64.encode64(body)} } doc['_attachments'] ||= {} doc['_attachments'].merge! end |
#attach_standalone_file(file_name, mime_type, body) ⇒ Object
25 26 27 |
# File 'lib/dolly/attachment.rb', line 25 def attach_standalone_file file_name, mime_type, body self.class.connection.attach id_as_resource, CGI.escape(file_name), body, { 'Content-Type' => mime_type } end |