Class: MailRoom::Coordinator
- Inherits:
-
Object
- Object
- MailRoom::Coordinator
- Defined in:
- lib/mail_room/coordinator.rb
Overview
Coordinate the mailbox watchers
Instance Attribute Summary collapse
-
#health_check ⇒ Object
Returns the value of attribute health_check.
-
#running ⇒ Object
(also: #running?)
Returns the value of attribute running.
-
#watchers ⇒ Object
Returns the value of attribute watchers.
Instance Method Summary collapse
-
#initialize(mailboxes, health_check = nil) ⇒ Coordinator
constructor
build watchers for a set of mailboxes.
-
#quit ⇒ Object
quit each of the watchers when we’re done running.
-
#run ⇒ Object
start each of the watchers to running.
Constructor Details
#initialize(mailboxes, health_check = nil) ⇒ Coordinator
build watchers for a set of mailboxes
10 11 12 13 14 15 |
# File 'lib/mail_room/coordinator.rb', line 10 def initialize(mailboxes, health_check = nil) self.watchers = [] @health_check = health_check mailboxes.each {|box| self.watchers << MailboxWatcher.new(box)} end |
Instance Attribute Details
#health_check ⇒ Object
Returns the value of attribute health_check.
5 6 7 |
# File 'lib/mail_room/coordinator.rb', line 5 def health_check @health_check end |
#running ⇒ Object Also known as: running?
Returns the value of attribute running.
5 6 7 |
# File 'lib/mail_room/coordinator.rb', line 5 def running @running end |
#watchers ⇒ Object
Returns the value of attribute watchers.
5 6 7 |
# File 'lib/mail_room/coordinator.rb', line 5 def watchers @watchers end |
Instance Method Details
#quit ⇒ Object
quit each of the watchers when we’re done running
32 33 34 35 |
# File 'lib/mail_room/coordinator.rb', line 32 def quit health_check&.quit watchers.each(&:quit) end |
#run ⇒ Object
start each of the watchers to running
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mail_room/coordinator.rb', line 20 def run health_check&.run watchers.each(&:run) self.running = true sleep_while_running ensure quit end |