File: mail_ext.rb

package info (click to toggle)
ruby-email-spec 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 980 kB
  • sloc: ruby: 2,420; makefile: 3
file content (16 lines) | stat: -rw-r--r-- 371 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module EmailSpec::MailExt
  def default_part
    @default_part ||= html_part || text_part || self
  end

  def default_part_body
    # Calling to_str as we want the actual String object
    HTMLEntities.new.decode(default_part.body.to_s.to_str)
  end

  def html
    html_part ? html_part.body.raw_source : nil
  end
end

Mail::Message.send(:include, EmailSpec::MailExt)