Sha256: 6cc4e23a648a4d03cd69a0bde9dc8f8fb53e815c8ea829ce95abc6ec91a3de12

Contents?: true

Size: 859 Bytes

Versions: 4

Compression:

Stored size: 859 Bytes

Contents

module MailRoom
  Mailbox = Struct.new(*[
    :email,
    :password,
    :name,
    :delivery_method, # :noop, :logger, :postback, :letter_opener
    :log_path, # for logger
    :delivery_url, # for postback
    :delivery_token, # for postback
    :location # for letter_opener
  ])

  class Mailbox
    def initialize(attributes={})
      super(*attributes.values_at(*members))

      require_relative("./delivery/#{(delivery_method || 'postback')}")
    end

    # move to a mailbox deliverer class?
    def delivery_klass
      case delivery_method
      when "noop"
        Delivery::Noop
      when "logger"
        Delivery::Logger
      when "letter_opener"
        Delivery::LetterOpener
      else
        Delivery::Postback
      end
    end

    def deliver(message)
      delivery_klass.new(self).deliver(message.attr['RFC822'])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mail_room-0.2.0 lib/mail_room/mailbox.rb
mail_room-0.1.0 lib/mail_room/mailbox.rb
mail_room-0.0.3 lib/mail_room/mailbox.rb
mail_room-0.0.2 lib/mail_room/mailbox.rb