class Guacamole::Configuration::ConfigStruct
A wrapper object to handle both configuration from a connection URI and a hash.
Attributes
database[R]
graph[R]
password[R]
url[R]
username[R]
Public Class Methods
new(config_hash_or_url)
click to toggle source
# File lib/guacamole/configuration.rb, line 75 def initialize(config_hash_or_url) case config_hash_or_url when Hash init_from_hash(config_hash_or_url) when String init_from_uri_string(config_hash_or_url) end end
Private Instance Methods
init_from_hash(hash)
click to toggle source
# File lib/guacamole/configuration.rb, line 96 def init_from_hash(hash) @username = hash['username'] @password = hash['password'] @database = hash['database'] @graph = hash['graph'] @url = "#{hash['protocol']}://#{hash['host']}:#{hash['port']}" end
init_from_uri_string(uri_string)
click to toggle source
# File lib/guacamole/configuration.rb, line 86 def init_from_uri_string(uri_string) uri = URI.parse(uri_string) @username = uri.user @password = uri.password uri.user = nil uri.path.match(%r{/_db/(?<db_name>\w+)/?}) { |match| @database = match[:db_name] } @url = "#{uri.scheme}://#{uri.hostname}:#{uri.port}" end