6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/faye-rails/routing_hooks.rb', line 6
def faye_server(mount_path, options={}, &block)
defaults = {
:mount => mount_path||'/faye',
:timeout => 25,
:extensions => nil,
:engine => nil,
:ping => nil,
:server => 'thin'
}
unknown_options = options.keys - defaults.keys
if unknown_options.one?
raise ArgumentError, "Unknown option: #{unknown_options.first}."
elsif unknown_options.any?
raise ArgumentError, "Unknown options: #{unknown_options * ", "}."
end
options = defaults.merge(options)
Faye::WebSocket.load_adapter(options.delete(:server))
adapter = FayeRails::RackAdapter.new(options)
adapter.instance_eval(&block) if block.respond_to? :call
match options[:mount] => adapter
end
|