Module: Roda::RodaPlugins::Mailer::ResponseMethods
- Defined in:
- lib/roda/plugins/mailer.rb
Instance Attribute Summary collapse
-
#mail ⇒ Object
The mail object related to the current request.
Instance Method Summary collapse
-
#finish ⇒ Object
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.
Instance Attribute Details
#mail ⇒ Object
The mail object related to the current request.
159 160 161 |
# File 'lib/roda/plugins/mailer.rb', line 159 def mail @mail end |
Instance Method Details
#finish ⇒ Object
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.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/roda/plugins/mailer.rb', line 165 def finish if m = mail header_content_type = @headers.delete(CONTENT_TYPE) m.headers(@headers) m.body(@body.join) unless @body.empty? 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. && 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 |