Sha256: efafb17dfa53022384731f3f8f7c80fb1180f26b0f41024047633076a9ada8a0

Contents?: true

Size: 582 Bytes

Versions: 1

Compression:

Stored size: 582 Bytes

Contents

module PipeRpc
  class Hub::Servers
    def initialize
      @servers = Hash.new{ |hash, key| raise NoServerError.new("no server #{key}") }
    end

    def add(*servers)
      if servers.first.respond_to? :to_rpc_server_id
        servers.each{ |server| @servers[server.to_rpc_server_id] = server }
      else
        servers.first.each{ |id, server| @servers[id.to_sym] = server }
      end
    end

    def [](id)
      @servers[id.to_sym]
    end

    def remove(id)
      @servers.delete(id.to_sym)
    end

    def registered?(id)
      @servers.has_key?(id)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipe_rpc-2.1.0 lib/pipe_rpc/hub_servers.rb