Class: Emailfuse::Deliverer
- Inherits:
-
Object
- Object
- Emailfuse::Deliverer
- Defined in:
- lib/emailfuse/deliverer.rb
Defined Under Namespace
Classes: Attachment
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #api_token ⇒ Object
- #deliver!(rails_message) ⇒ Object
-
#initialize(settings) ⇒ Deliverer
constructor
A new instance of Deliverer.
Constructor Details
#initialize(settings) ⇒ Deliverer
Returns a new instance of Deliverer.
16 17 18 |
# File 'lib/emailfuse/deliverer.rb', line 16 def initialize(settings) self.settings = settings end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
14 15 16 |
# File 'lib/emailfuse/deliverer.rb', line 14 def settings @settings end |
Instance Method Details
#api_token ⇒ Object
20 21 22 |
# File 'lib/emailfuse/deliverer.rb', line 20 def api_token self.settings[:token] || Emailfuse.config.token end |
#deliver!(rails_message) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/emailfuse/deliverer.rb', line 24 def deliver!() attributes = { from: [:from], to: [:to].formatted, subject: .subject, html: extract_html(), text: extract_text() } [ :reply_to, :cc ].each do |key| attributes[key] = [key].formatted if [key] end unless ..empty? attributes[:attachments] = [] ..each do || attributes[:attachments] << Attachment.new(, encoding: "ascii-8bit") end end Email.create(**attributes) end |