Class: ServerList

Inherits:
Array
  • Object
show all
Defined in:
lib/faye-rails/server_list.rb

Instance Method Summary collapse

Instance Method Details

#<<(server) ⇒ Object Also known as: push



12
13
14
15
16
17
18
# File 'lib/faye-rails/server_list.rb', line 12

def <<(server)
  if at(server.endpoint).size == 0
    super
  else
    raise ArgumentError, "Server at mount point #{server.endpoint} is already present."
  end
end

#at(index) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/faye-rails/server_list.rb', line 2

def at(index)
  if index.is_a? String
    select do |server|
      server.endpoint == index
    end
  else
    super
  end
end

#clear!Object



21
22
23
24
25
26
# File 'lib/faye-rails/server_list.rb', line 21

def clear!
  self.each do |server|
    server.stop
  end
  clear
end