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