class MailRoom::Coordinator
Coordinate the mailbox watchers @author Tony Pitale
Attributes
running[RW]
running?[RW]
watchers[RW]
Public Class Methods
new(mailboxes)
click to toggle source
build watchers for a set of mailboxes @params mailboxes [Array<MailRoom::Mailbox>] mailboxes to be watched
# File lib/mail_room/coordinator.rb, line 9 def initialize(mailboxes) self.watchers = [] mailboxes.each {|box| self.watchers << MailboxWatcher.new(box)} end
Public Instance Methods
quit()
click to toggle source
quit each of the watchers when we're done running
# File lib/mail_room/coordinator.rb, line 29 def quit watchers.each(&:quit) end
run()
click to toggle source
start each of the watchers to running
# File lib/mail_room/coordinator.rb, line 18 def run watchers.each(&:run) self.running = true sleep_while_running ensure quit end
Private Instance Methods
sleep_while_running()
click to toggle source
@private
# File lib/mail_room/coordinator.rb, line 35 def sleep_while_running # do we need to sweep for dead watchers? # or do we let the mailbox rebuild connections while(running?) do; sleep 1; end end