lib/roda/plugins/mailer.rb
def finish
          if m = mail
            header_content_type = @headers.delete('Content-Type')
            m.headers(@headers)
            m.body(@body.join) unless @body.empty?
            mail_attachments.each do |a, block|
              m.add_file(*a)
              block.call if block
            end

            if content_type = header_content_type || roda_class.opts[:mailer][:content_type]
              if mail.multipart?
                if mail.content_type =~ /multipart\/mixed/ &&
                   mail.parts.length >= 2 &&
                   (part = mail.parts.find{|p| !p.attachment && p.content_type == "text/plain"})
                  part.content_type = content_type
                end
              else
                mail.content_type = content_type
              end
            end

            unless m.body.to_s.empty? && m.parts.empty? && @body.empty?
              m
            end
          else
            super
          end
        end
# If the related request was an email request, add any response headers
# to the email, as well as adding the response body to the email.
# Return the email unless no body was set for it, which would indicate
# that the routing tree did not handle the request.
If the related request was an email request, add any response headers
to the email, as well as adding the response body to the email.
Return the email unless no body was set for it, which would indicate
that the routing tree did not handle the request.
If the related request was an email request add any response headers to the email as well as adding the response body to the email . Return the email unless no body was set for it which would indicate that the routing tree did not handle the request .
def finish
          if m = mail
            header_content_type = @headers.delete('Content-Type')
            m.headers(@headers)
            m.body(@body.join) unless @body.empty?
            mail_attachments.each do |a, block|
              m.add_file(*a)
              block.call if block
            end
            if content_type = header_content_type || roda_class.opts[:mailer][:content_type]
              if mail.multipart?
                if mail.content_type =~ /multipart\/mixed/ &&
                   mail.parts.length >= 2 &&
                   (part = mail.parts.find{|p| !p.attachment && p.content_type == "text/plain"})
                  part.content_type = content_type
                end
              else
                mail.content_type = content_type
              end
            end
            unless m.body.to_s.empty? && m.parts.empty? && @body.empty?
              m
            end
          else
            super
          end
        end
def finish if m = mail header_content_type = @headers . delete ( 'Content-Type' ) m . headers ( @headers ) m . body ( @body . join ) unless @body . empty? mail_attachments . each do | a , block | m . add_file ( * a ) block . call if block end if content_type = header_content_type || roda_class . opts [ :mailer ] [ :content_type ] if mail . multipart? if mail . content_type =~ / multipart \/ mixed / && mail . parts . length >= 2 && ( part = mail . parts . find { | p | ! p . attachment && p . content_type == "text/plain" } ) part . content_type = content_type end else mail . content_type = content_type end end unless m . body . to_s . empty? && m . parts . empty? && @body . empty? m end else super end end
If the related request was an email request, add any response headers
to the email, as well as adding the response body to the email.
If the related request was an email request add any response headers to the email as well as adding the response body to the email .