Class: MailRoom::MailboxHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_room/mailbox_handler.rb

Overview

Fetches new email messages for delivery

Author:

  • Tony Pitale

Instance Method Summary collapse

Constructor Details

#initialize(mailbox, imap) ⇒ MailboxHandler

build a handler for this mailbox and our imap connection

Parameters:

  • mailbox (MailRoom::Mailbox)

    the mailbox configuration

  • imap (Net::IMAP::Connection)

    the open connection to gmail



8
9
10
11
# File 'lib/mail_room/mailbox_handler.rb', line 8

def initialize(mailbox, imap)
  @mailbox = mailbox
  @imap = imap
end

Instance Method Details

#processObject

deliver each of the new messages



14
15
16
17
18
19
20
21
22
23
# File 'lib/mail_room/mailbox_handler.rb', line 14

def process
  # return if idling? || !running?

  new_messages.each do |msg|
    # puts msg.attr['RFC822']

    # loop over delivery methods and deliver each
    @mailbox.deliver(msg)
  end
end