Class: DraftBox::DeliveryMethod
- Inherits:
-
Object
- Object
- DraftBox::DeliveryMethod
- Defined in:
- lib/draft_box/delivery_method.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(options = {}) ⇒ DeliveryMethod
constructor
A new instance of DeliveryMethod.
Constructor Details
#initialize(options = {}) ⇒ DeliveryMethod
Returns a new instance of DeliveryMethod.
5 6 7 |
# File 'lib/draft_box/delivery_method.rb', line 5 def initialize( = {}) self.settings = end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
3 4 5 |
# File 'lib/draft_box/delivery_method.rb', line 3 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/draft_box/delivery_method.rb', line 9 def deliver!(mail) validate_mail!(mail) ActiveRecord::Base.transaction do email = DraftBox::Email.create!( subject: mail.subject, body: mail.parts.empty? ? mail.body.to_s : mail.parts.find { |p| p.content_type.start_with?('text/html', 'text/plain') }&.body.to_s, from: mail.from.first, recipients: mail.to, carbon_copies: mail.cc || [], blind_copies: mail.bcc || [] ) mail..each do || email..create!( filename: .filename, content_type: .content_type, data: .body.to_s ) end end end |