Sha256: 414ec5b97c3345d0343571f20f39620f46c8d930ca82414087aa1adc9d8ddb01

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

require 'yaml'
module LetterOpener
  class DeliveryMethod

    def initialize(options = {})
      raise InvalidOption, "A location option is required when using the Letter Opener delivery method" if LetterOpener.location.nil?
      self.settings = options
    end

    def deliver!(mail)
      location = File.join(LetterOpener.location, "#{Time.now.to_i}_#{Digest::SHA1.hexdigest(mail.encoded)[0..6]}")
      messages = Message.rendered_messages(location, mail)
      info = {}
      info[:subject] = mail.subject.to_s
      info[:to]      = mail.to.join(',')
      info[:from]    = mail.from.join(',')
      File.open(File.join(location, 'info.yml'), 'w') {|f| f.write YAML.dump(info) }
      messages
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
letter_opener-web-0.1.0 lib/letter_opener/delivery_method.rb