Class: EventMachine::DistributedNotificationWatch

Inherits:
Object
  • Object
show all
Defined in:
lib/eventmachine-distributed-notification.rb

Instance Method Summary collapse

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, )
end

#startObject



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

#stopObject



38
39
40
41
# File 'lib/eventmachine-distributed-notification.rb', line 38

def stop
  @observers.map(&:unobserve)
  @timer.cancel if @timer
end