Class: Disloku::Config::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/disloku/config/Connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Connection

Returns a new instance of Connection.



10
11
12
13
14
15
16
17
18
19
# File 'lib/disloku/config/Connection.rb', line 10

def initialize(config)
	@host = config["host"].value()
	@user = config["user"].value() if !config["user"].nil?
	@options = {}
	addOption(config, :password)
	addOption(config, :port)
	addOption(config, :keys, true)

	@hash = Digest::SHA1.hexdigest([@host, @user, @options].join())
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



8
9
10
# File 'lib/disloku/config/Connection.rb', line 8

def hash
  @hash
end

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/disloku/config/Connection.rb', line 8

def host
  @host
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/disloku/config/Connection.rb', line 8

def options
  @options
end

#userObject

Returns the value of attribute user.



8
9
10
# File 'lib/disloku/config/Connection.rb', line 8

def user
  @user
end

Instance Method Details

#addOption(config, key, unwrap = false) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/disloku/config/Connection.rb', line 21

def addOption(config, key, unwrap = false)
	value = config[key.to_s()]
	if (!value.nil?)
		if (unwrap)
			@options[key] = value.value().map() { |e| e.value() }
		else
			@options[key] = value.value()
		end
	end
end