module PipeRpc class Hub::Servers def initialize @servers = Hash.new{ |hash, key| raise NoServerError.new("no server #{key.inspect}") } end def add(server) id, server = if server.respond_to? :__rpc_server_id__ [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 def registered?(id) @servers.has_key?(id) end def registered_ids @servers.keys end def [](id) @servers[id] end def remove(id) @servers.delete(id) end end end