Class: Twelvefactor::Environment::Mailer::Smtp
- Inherits:
-
Object
- Object
- Twelvefactor::Environment::Mailer::Smtp
- Defined in:
- lib/twelvefactor/environment/mailer/smtp.rb
Overview
frozen_string_literal: true
Class Method Summary collapse
- .apply(app, mailer_url) ⇒ Object
- .basic_settings(url) ⇒ Object
- .extra_settings(query) ⇒ Object
- .smtp_settings(url) ⇒ Object
Class Method Details
.apply(app, mailer_url) ⇒ Object
5 6 7 8 9 |
# File 'lib/twelvefactor/environment/mailer/smtp.rb', line 5 def self.apply app, mailer_url config = app.config config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = smtp_settings mailer_url end |
.basic_settings(url) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/twelvefactor/environment/mailer/smtp.rb', line 17 def self.basic_settings url { address: url.host, port: url.port, user_name: url.user, password: url.password } end |
.extra_settings(query) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/twelvefactor/environment/mailer/smtp.rb', line 26 def self.extra_settings query return {} unless query CGI .parse(query) .map { |k, val| [k.to_sym, val.first] } .to_h end |
.smtp_settings(url) ⇒ Object
11 12 13 14 15 |
# File 'lib/twelvefactor/environment/mailer/smtp.rb', line 11 def self.smtp_settings url basic_settings(url) .merge(extra_settings(url.query)) .compact end |