Class: ConnectionFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/audit/lib/connection/connection_factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ConnectionFactory

Returns a new instance of ConnectionFactory.



5
6
7
8
9
10
11
# File 'lib/audit/lib/connection/connection_factory.rb', line 5

def initialize(options)
	if options[:logger] then
		@logger = options[:logger]
	else
		@logger = Logger.new(STDOUT)
	end
end

Instance Method Details

#create(options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/audit/lib/connection/connection_factory.rb', line 13

def create(options)
	raise "Need option :connection_type" unless options[:connection_type]
	raise "Need option :connection_params" unless options[:connection_params] 

	case options[:connection_type]
		when :ssh
			return SshConnection.new({:connection_params => options[:connection_params], :logger => @logger})
		when :ami
			return AmiConnection.new({:connection_params => options[:connection_params], :logger => @logger})
		else
			raise "Unknown connection type"
	end
end