class PipeRpc::Hub::Servers

Public Class Methods

new() click to toggle source
# File lib/pipe_rpc/hub_servers.rb, line 3
def initialize
  @servers = Hash.new{ |hash, key| raise NoServerError.new("no server #{key.inspect}") }
end

Public Instance Methods

[](id) click to toggle source
# File lib/pipe_rpc/hub_servers.rb, line 31
def [](id)
  @servers[id]
end
add(server) click to toggle source
# File lib/pipe_rpc/hub_servers.rb, line 7
def add(server)
  id, server = if Server === server
    [server.__rpc_server_id__, server]
  else
    server.first
  end

  raise ServerRegistrationError.new("server id #{id.inspect} no symbol") unless id.is_a? Symbol

  if registered? id
    raise ServerRegistrationError.new("server id #{id.inspect} already used for another server")
  else
    @servers[id] = server
  end
end
registered?(id) click to toggle source
# File lib/pipe_rpc/hub_servers.rb, line 23
def registered?(id)
  @servers.has_key?(id)
end
registered_ids() click to toggle source
# File lib/pipe_rpc/hub_servers.rb, line 27
def registered_ids
  @servers.keys
end
remove(id) click to toggle source
# File lib/pipe_rpc/hub_servers.rb, line 35
def remove(id)
  @servers.delete(id)
end