Class: Bipbop::Client::ServiceDiscovery
- Inherits:
-
Object
- Object
- Bipbop::Client::ServiceDiscovery
- Defined in:
- lib/bipbop/service_discovery.rb
Direct Known Subclasses
Constant Summary collapse
- KEY_DATABASE_NAME =
"name"
- KEY_DATABASE_DESCRIPTION =
"description"
- KEY_DATABASE_URL =
"url"
Class Method Summary collapse
Instance Method Summary collapse
- #get_database(name) ⇒ Object
-
#initialize(ws, databases) ⇒ ServiceDiscovery
constructor
A new instance of ServiceDiscovery.
- #list_databases ⇒ Object
Constructor Details
#initialize(ws, databases) ⇒ ServiceDiscovery
Returns a new instance of ServiceDiscovery.
12 13 14 15 |
# File 'lib/bipbop/service_discovery.rb', line 12 def initialize (ws, databases) @ws = ws @list_databases = databases end |
Class Method Details
.factory(ws, parameters = {}) ⇒ Object
17 18 19 |
# File 'lib/bipbop/service_discovery.rb', line 17 def self.factory(ws, parameters = {}) ServiceDiscovery.new(ws, ws.post("SELECT FROM 'INFO'.'INFO'", parameters)) end |
Instance Method Details
#get_database(name) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/bipbop/service_discovery.rb', line 31 def get_database(name) database = @list_databases.xpath("/BPQL/body/database[@name='%s']" % [name.gsub(/[^a-z0-9]/i, '')]) if (database.length == 0) raise Exception, "Can't find that database." end Bipbop::Client::Database.new(@ws, database.first, @list_databases) end |
#list_databases ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/bipbop/service_discovery.rb', line 21 def list_databases @list_databases.xpath("//BPQL//body//database").each { |node| yield [ KEY_DATABASE_NAME => node["name"], KEY_DATABASE_DESCRIPTION => node["description"], KEY_DATABASE_URL => node["url"] ] } end |