Class: MList::Email
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MList::Email
- Includes:
- Util::EmailHelpers, Util::TMailReaders
- Defined in:
- lib/mlist/email.rb
Constant Summary
Constants included from Util::EmailHelpers
Util::EmailHelpers::BRACKETS_RE, Util::EmailHelpers::HTML_ESCAPE, Util::EmailHelpers::REGARD_RE
Instance Method Summary collapse
- #been_here?(list) ⇒ Boolean
-
#bounce? ⇒ Boolean
Answers true if this email is a bounce.
- #from ⇒ Object
-
#list_addresses ⇒ Object
Answers the usable destination addresses of the email.
-
#method_missing(symbol, *args, &block) ⇒ Object
Provide reader delegation to most of the underlying TMail::Mail methods, excluding those overridden by this Class and the [] method (an ActiveRecord method).
- #respond_to?(method) ⇒ Boolean
- #tmail ⇒ Object
- #tmail=(tmail) ⇒ Object
Methods included from Util::TMailReaders
#date, #from_address, #html, #identifier, #mailer, #text, #text_plain_part
Methods included from Util::EmailHelpers
#bracket, #escape_once, #header_sanitizer, #html_to_text, #normalize_new_lines, #remove_brackets, #remove_regard, #sanitize_header, #text_to_html, #text_to_quoted
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
Provide reader delegation to most of the underlying TMail::Mail methods, excluding those overridden by this Class and the [] method (an ActiveRecord method).
43 44 45 46 47 48 49 |
# File 'lib/mlist/email.rb', line 43 def method_missing(symbol, *args, &block) # :nodoc: if symbol.to_s !~ /=\Z/ && symbol != :[] && symbol != :source && tmail.respond_to?(symbol) tmail.__send__(symbol, *args, &block) else super end end |
Instance Method Details
#been_here?(list) ⇒ Boolean
9 10 11 |
# File 'lib/mlist/email.rb', line 9 def been_here?(list) tmail.header_string('x-beenthere') == list.address end |
#bounce? ⇒ Boolean
Answers true if this email is a bounce.
TODO Delegate to the email_server’s bounce detector.
27 28 29 |
# File 'lib/mlist/email.rb', line 27 def bounce? tmail.header_string('to') =~ /mlist-/ end |
#from ⇒ Object
13 14 15 |
# File 'lib/mlist/email.rb', line 13 def from tmail.header_string('from') end |
#list_addresses ⇒ Object
Answers the usable destination addresses of the email.
19 20 21 |
# File 'lib/mlist/email.rb', line 19 def list_addresses bounce? ? tmail.header_string('to').match(/\Amlist-(.*)\Z/)[1] : tmail.to.collect(&:downcase) end |
#respond_to?(method) ⇒ Boolean
51 52 53 |
# File 'lib/mlist/email.rb', line 51 def respond_to?(method) super || (method.to_s !~ /=\Z/ && tmail.respond_to?(method)) end |
#tmail ⇒ Object
36 37 38 |
# File 'lib/mlist/email.rb', line 36 def tmail @tmail ||= TMail::Mail.parse(source) end |
#tmail=(tmail) ⇒ Object
31 32 33 34 |
# File 'lib/mlist/email.rb', line 31 def tmail=(tmail) @tmail = tmail write_attribute(:source, tmail.port.read_all) end |