Class: PalavaMachine::SocketStore

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/palava_machine/socket_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(connections = {}) ⇒ SocketStore

Returns a new instance of SocketStore.



9
10
11
# File 'lib/palava_machine/socket_store.rb', line 9

def initialize(connections = {})
  @connections = connections.dup
end

Instance Method Details

#dupObject



42
43
44
# File 'lib/palava_machine/socket_store.rb', line 42

def dup
  SocketStore.new(@connections) # TODO verify (shallow)
end

#each(&block) ⇒ Object



30
31
32
# File 'lib/palava_machine/socket_store.rb', line 30

def each(&block)
  @connections.each(&block)
end

#get_connection(id) ⇒ Object Also known as: []



25
26
27
# File 'lib/palava_machine/socket_store.rb', line 25

def get_connection(id)
  @connections.key(id)
end

#get_connection_id(ws) ⇒ Object



21
22
23
# File 'lib/palava_machine/socket_store.rb', line 21

def get_connection_id(ws)
  @connections[ws]
end

#idsObject



38
39
40
# File 'lib/palava_machine/socket_store.rb', line 38

def ids
  @connections.values
end

#register_connection(ws) ⇒ Object



13
14
15
# File 'lib/palava_machine/socket_store.rb', line 13

def register_connection(ws)
  @connections[ws] = SecureRandom.uuid
end

#socketsObject



34
35
36
# File 'lib/palava_machine/socket_store.rb', line 34

def sockets
  @connections.keys
end

#unregister_connection(ws) ⇒ Object



17
18
19
# File 'lib/palava_machine/socket_store.rb', line 17

def unregister_connection(ws)
  @connections.delete(ws)
end