Class: Goatmail::DeliveryMethod
- Inherits:
-
LetterOpener::DeliveryMethod
- Object
- LetterOpener::DeliveryMethod
- Goatmail::DeliveryMethod
- Defined in:
- lib/goatmail/delivery_method.rb
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.
6 7 8 9 10 |
# File 'lib/goatmail/delivery_method.rb', line 6 def initialize( = {}) [:location] ||= Goatmail.location super raise InvalidOption, "A location option is required when using the Goatmail delivery method" if Goatmail.location.nil? end |
Instance Method Details
#deliver!(mail) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/goatmail/delivery_method.rb', line 12 def deliver!(mail) validate_mail!(mail) location = File.join(settings[:location], "#{Time.now.to_f.to_s.tr('.', '_')}_#{Digest::SHA1.hexdigest(mail.encoded)[0..6]}") = LetterOpener::Message.(mail, location: location, message_template: settings[:message_template]) = { subject: mail.subject.to_s, to: mail.to.join(", "), from: mail.from.join(', ') } File.open(File.join(location, 'meta'), 'wb') {|f| Marshal.dump(, f)} end |