Sha256: 94d085dfadb5b51eae4dd0789fe875a19f32296975ca4216b1c678c9ca156a4d

Contents?: true

Size: 591 Bytes

Versions: 1

Compression:

Stored size: 591 Bytes

Contents

module LetterOpener
  class DeliveryMethod
    class InvalidOption < StandardError; end

    attr_accessor :settings

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

    def deliver!(mail)
      location = File.join(settings[:location], "#{Time.now.to_i}_#{Digest::SHA1.hexdigest(mail.encoded)[0..6]}")
      messages = Message.rendered_messages(location, mail)
      Launchy.open(URI.escape(messages.first.filepath))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
letter_opener-1.1.0 lib/letter_opener/delivery_method.rb