4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/protein/transport.rb', line 4
def define(transport, opts = {})
if transport.is_a?(Class) || transport.is_a?(String)
transport_class
elsif transport.is_a?(Symbol)
transport_base_class =
case transport
when :http
Protein::HTTPAdapter
when :amqp
Protein::AMQPAdapter
else
raise(DefinitionError, "invalid transport: #{transport.inspect}")
end
transport_class = Class.new(transport_base_class)
transport_class.from_hash(opts)
transport_class
else
raise(DefinitionError, "invalid transport definition")
end
end
|