Class: Disloku::Config::Connection
- Inherits:
-
Object
- Object
- Disloku::Config::Connection
- Defined in:
- lib/disloku/config/Connection.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#host ⇒ Object
Returns the value of attribute host.
-
#options ⇒ Object
Returns the value of attribute options.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #addOption(config, key, unwrap = false) ⇒ Object
-
#initialize(config) ⇒ Connection
constructor
A new instance of Connection.
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
#hash ⇒ Object
Returns the value of attribute hash.
8 9 10 |
# File 'lib/disloku/config/Connection.rb', line 8 def hash @hash end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/disloku/config/Connection.rb', line 8 def host @host end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/disloku/config/Connection.rb', line 8 def @options end |
#user ⇒ Object
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 |