Class: Tusk::Observable::DRb::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/tusk/observable/drb.rb

Constant Summary collapse

URI =
'druby://localhost:8787'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



57
58
59
# File 'lib/tusk/observable/drb.rb', line 57

def initialize
  @channels = Hash.new { |h,k| h[k] = {} }
end

Class Method Details

.startObject



49
50
51
# File 'lib/tusk/observable/drb.rb', line 49

def self.start
  ::DRb.start_service URI, new
end

.stopObject



53
54
55
# File 'lib/tusk/observable/drb.rb', line 53

def self.stop
  ::DRb.stop_service
end

Instance Method Details

#delete(channel) ⇒ Object



75
76
77
# File 'lib/tusk/observable/drb.rb', line 75

def delete channel
  @channels.delete channel
end

#delete_observer(channel, o) ⇒ Object



71
72
73
# File 'lib/tusk/observable/drb.rb', line 71

def delete_observer channel, o
  @channels[channel].delete o
end

#signal(channel, args) ⇒ Object



65
66
67
68
69
# File 'lib/tusk/observable/drb.rb', line 65

def signal channel, args
  @channels[channel].each { |proxy,|
    proxy.notify args
  }
end

#watch(channel, proxy) ⇒ Object



61
62
63
# File 'lib/tusk/observable/drb.rb', line 61

def watch channel, proxy
  @channels[channel][proxy] = proxy
end