Module: Postmark::MessageHelper
- Extended by:
- MessageHelper
- Included in:
- MessageHelper
- Defined in:
- lib/postmark/helpers/message_helper.rb
Instance Method Summary collapse
- #attachments_to_postmark(attachments) ⇒ Object
- #encode_in_base64(data) ⇒ Object
- #headers_to_postmark(headers) ⇒ Object
- #to_postmark(message = {}) ⇒ Object
Instance Method Details
#attachments_to_postmark(attachments) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/postmark/helpers/message_helper.rb', line 34 def () wrap_in_array().map do |item| if item.is_a?(Hash) HashHelper.to_postmark(item) elsif item.is_a?(File) { "Name" => item.path.split("/")[-1], "Content" => encode_in_base64(IO.read(item.path)), "ContentType" => "application/octet-stream" } end end end |
#encode_in_base64(data) ⇒ Object
48 49 50 |
# File 'lib/postmark/helpers/message_helper.rb', line 48 def encode_in_base64(data) [data].pack('m') end |
#headers_to_postmark(headers) ⇒ Object
28 29 30 31 32 |
# File 'lib/postmark/helpers/message_helper.rb', line 28 def headers_to_postmark(headers) wrap_in_array(headers).map do |item| HashHelper.to_postmark(item) end end |
#to_postmark(message = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/postmark/helpers/message_helper.rb', line 6 def to_postmark( = {}) = .dup %w(to reply_to cc bcc).each do |field| [field.to_sym] = Array[*[field.to_sym]].join(", ") end if [:headers] [:headers] = headers_to_postmark([:headers]) end if [:attachments] [:attachments] = ([:attachments]) end if [:track_links] [:track_links] = ::Postmark::Inflector.to_postmark([:track_links]) end HashHelper.to_postmark() end |