Module: Mailbot::Mailer
- Defined in:
- lib/mailbot/mailer.rb
Constant Summary collapse
- BLOCK_SYMBOL =
:mailbot_mailer_block
Class Method Summary collapse
Class Method Details
.block ⇒ Object
17 18 19 |
# File 'lib/mailbot/mailer.rb', line 17 def block Thread.current[BLOCK_SYMBOL] || default end |
.default ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mailbot/mailer.rb', line 21 def default ->(subject, body) do mailgun = Mailgun::Client.new ENV["MAILBOT_MAILGUN_API_KEY"] params = { :from => ENV["MAILBOT_MAIL_FROM"], :to => ENV["MAILBOT_MAIL_TO"], :subject => subject, :html => body } mailgun. ENV["MAILBOT_MAILGUN_DOMAIN"], params end end |
.deliver(subject: "", body: "") ⇒ Object
9 10 11 |
# File 'lib/mailbot/mailer.rb', line 9 def deliver(subject: "", body: "") block.call subject, body end |
.set(&block) ⇒ Object
13 14 15 |
# File 'lib/mailbot/mailer.rb', line 13 def set(&block) Thread.current[BLOCK_SYMBOL] = block end |