Class: SubjectFilter
- Inherits:
-
BasicFilter
- Object
- BasicFilter
- SubjectFilter
- Defined in:
- lib/filter/subject_filter.rb
Overview
Checks the subject of the incomming message for a specific password and rejects the mail if the passwort is not present.
Instance Method Summary collapse
-
#initialize(password, charset = "UTF-8") ⇒ SubjectFilter
constructor
A new instance of SubjectFilter.
-
#passed_filter?(tmail) ⇒ Boolean
Returns true if password is present.
Constructor Details
#initialize(password, charset = "UTF-8") ⇒ SubjectFilter
Returns a new instance of SubjectFilter.
5 6 7 8 |
# File 'lib/filter/subject_filter.rb', line 5 def initialize(password, charset = "UTF-8") super(charset) @password = password end |
Instance Method Details
#passed_filter?(tmail) ⇒ Boolean
Returns true if password is present. Password will be removed from the subject.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/filter/subject_filter.rb', line 12 def passed_filter?(tmail) password_is_present = !tmail.subject.match(@password).nil? password_matcher = Regexp.new("#{@password}\s+") if password_is_present then # Remove password from the subject tmail.subject = tmail.subject(@charset).gsub(password_matcher, "") end return password_is_present end |