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