Class: MailWhitelist
- Inherits:
-
Object
- Object
- MailWhitelist
- Defined in:
- lib/mail_whitelist.rb,
lib/mail_whitelist/version.rb
Overview
Filter mails with a specific whitelist of e-mailaddresses and only leaves those in the ‘to’.
Constant Summary collapse
- VERSION =
'1.1.0'.freeze
Instance Attribute Summary collapse
-
#fallback ⇒ Object
readonly
Returns the value of attribute fallback.
-
#whitelist ⇒ Object
readonly
Returns the value of attribute whitelist.
Instance Method Summary collapse
- #delivering_email(mail) ⇒ Object
-
#initialize(whitelist, fallback = nil) ⇒ MailWhitelist
constructor
A new instance of MailWhitelist.
Constructor Details
#initialize(whitelist, fallback = nil) ⇒ MailWhitelist
Returns a new instance of MailWhitelist.
10 11 12 13 |
# File 'lib/mail_whitelist.rb', line 10 def initialize(whitelist, fallback = nil) @whitelist = whitelist @fallback = fallback end |
Instance Attribute Details
#fallback ⇒ Object (readonly)
Returns the value of attribute fallback.
6 7 8 |
# File 'lib/mail_whitelist.rb', line 6 def fallback @fallback end |
#whitelist ⇒ Object (readonly)
Returns the value of attribute whitelist.
6 7 8 |
# File 'lib/mail_whitelist.rb', line 6 def whitelist @whitelist end |
Instance Method Details
#delivering_email(mail) ⇒ Object
15 16 17 18 |
# File 'lib/mail_whitelist.rb', line 15 def delivering_email(mail) mail.to = mail.to.select { |recipient| whitelisted?(recipient) } mail.to = [fallback] unless mail.to.any? end |