Sha256: 7dc2776efbe839baf017b07fde5b7f221b4bc9c6c2fa601f50e9b5a1fa2c7cfd

Contents?: true

Size: 708 Bytes

Versions: 20

Compression:

Stored size: 708 Bytes

Contents

module MList
  module EmailServer
    class Base
      attr_reader :settings
      
      def initialize(settings)
        @settings = {
          :domain => ::Socket.gethostname
        }.merge(settings)
        
        @uuid = UUID.new
        @receivers = []
      end
      
      def deliver(tmail)
        raise 'Implement actual delivery mechanism in subclasses'
      end
      
      def generate_message_id
        "#{@uuid.generate}@#{@settings[:domain]}"
      end
      
      def receive(tmail)
        email = MList::Email.new(:tmail => tmail)
        @receivers.each { |r| r.receive_email(email) }
      end
      
      def receiver(rx)
        @receivers << rx
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
aiwilliams-mlist-0.1.3 lib/mlist/email_server/base.rb
aiwilliams-mlist-0.1.4 lib/mlist/email_server/base.rb
aiwilliams-mlist-0.1.5 lib/mlist/email_server/base.rb
aiwilliams-mlist-0.1.6 lib/mlist/email_server/base.rb
aiwilliams-mlist-0.1.7 lib/mlist/email_server/base.rb
aiwilliams-mlist-0.1.8 lib/mlist/email_server/base.rb
mlist-0.1.23 lib/mlist/email_server/base.rb
mlist-0.1.22 lib/mlist/email_server/base.rb
mlist-0.1.21 lib/mlist/email_server/base.rb
mlist-0.1.20 lib/mlist/email_server/base.rb
mlist-0.1.19 lib/mlist/email_server/base.rb
mlist-0.1.18 lib/mlist/email_server/base.rb
mlist-0.1.17 lib/mlist/email_server/base.rb
mlist-0.1.16 lib/mlist/email_server/base.rb
mlist-0.1.14 lib/mlist/email_server/base.rb
mlist-0.1.13 lib/mlist/email_server/base.rb
mlist-0.1.12 lib/mlist/email_server/base.rb
mlist-0.1.11 lib/mlist/email_server/base.rb
mlist-0.1.10 lib/mlist/email_server/base.rb
mlist-0.1.9 lib/mlist/email_server/base.rb