Class: SafetyMailer::Carrier
- Inherits:
-
Object
- Object
- SafetyMailer::Carrier
- Defined in:
- lib/safety_mailer/safety_mailer.rb
Instance Attribute Summary collapse
-
#mail ⇒ Object
Returns the value of attribute mail.
-
#matchers ⇒ Object
Returns the value of attribute matchers.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(params = {}) ⇒ Carrier
constructor
A new instance of Carrier.
Constructor Details
#initialize(params = {}) ⇒ Carrier
Returns a new instance of Carrier.
5 6 7 8 9 10 11 |
# File 'lib/safety_mailer/safety_mailer.rb', line 5 def initialize(params = {}) self.matchers = params[:allowed_matchers] || [] self.settings = params[:delivery_method_settings] || {} delivery_method = params[:delivery_method] || :smtp @delivery_method = Mail::Configuration.instance.lookup_delivery_method(delivery_method).new(settings) = {} end |
Instance Attribute Details
#mail ⇒ Object
Returns the value of attribute mail.
3 4 5 |
# File 'lib/safety_mailer/safety_mailer.rb', line 3 def mail @mail end |
#matchers ⇒ Object
Returns the value of attribute matchers.
3 4 5 |
# File 'lib/safety_mailer/safety_mailer.rb', line 3 def matchers @matchers end |
#settings ⇒ Object
Returns the value of attribute settings.
3 4 5 |
# File 'lib/safety_mailer/safety_mailer.rb', line 3 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/safety_mailer/safety_mailer.rb', line 13 def deliver!(mail) self.mail = mail allowed = filter(recipients) if allowed.empty? log "*** safety_mailer - no allowed recipients ... suppressing delivery altogether" return end mail['X-SMTPAPI'].value = prepare_sendgrid_delivery(allowed) if sendgrid? mail.to = allowed @delivery_method.deliver!(mail) end |