Class: EventMachine::DistributedNotificationWatch
- Inherits:
-
Object
- Object
- EventMachine::DistributedNotificationWatch
- Defined in:
- lib/eventmachine-distributed-notification.rb
Instance Method Summary collapse
-
#initialize(names) ⇒ DistributedNotificationWatch
constructor
A new instance of DistributedNotificationWatch.
- #notify(name, user_info) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(names) ⇒ DistributedNotificationWatch
Returns a new instance of DistributedNotificationWatch.
21 22 23 24 25 26 |
# File 'lib/eventmachine-distributed-notification.rb', line 21 def initialize(names) names = names.kind_of?(Array) ? names : [names] @observers = names.map do |name| DistributedNotification::ObserverNative.new(name, self) end end |
Instance Method Details
#notify(name, user_info) ⇒ Object
28 29 |
# File 'lib/eventmachine-distributed-notification.rb', line 28 def notify(name, user_info) end |
#start ⇒ Object
31 32 33 34 35 36 |
# File 'lib/eventmachine-distributed-notification.rb', line 31 def start @observers.map(&:observe) @timer = EventMachine::add_periodic_timer(1) do @observers.map(&:run) end end |
#stop ⇒ Object
38 39 40 41 |
# File 'lib/eventmachine-distributed-notification.rb', line 38 def stop @observers.map(&:unobserve) @timer.cancel if @timer end |