Class: CloudDB::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/clouddb/database.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, name) ⇒ Database

Creates a new CloudDB::Database object representing a database.



7
8
9
10
11
12
13
14
15
16
# File 'lib/clouddb/database.rb', line 7

def initialize(instance, name)
  @connection     = instance.connection
  @instance       = instance
  @name           = name
  @dbmgmthost     = @connection.dbmgmthost
  @dbmgmtpath     = @connection.dbmgmtpath
  @dbmgmtport     = @connection.dbmgmtport
  @dbmgmtscheme   = @connection.dbmgmtscheme
  self
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/clouddb/database.rb', line 4

def name
  @name
end

Instance Method Details

#destroy!Object

Deletes the current Database object and removes it from the instance. Returns true if successful, raises an exception if not.



20
21
22
23
24
# File 'lib/clouddb/database.rb', line 20

def destroy!
  response = @connection.dbreq("DELETE",@dbmgmthost,"#{@dbmgmtpath}/instances/#{CloudDB.escape(@instance.id.to_s)}/databases/#{CloudDB.escape(@name.to_s)}",@dbmgmtport,@dbmgmtscheme)
  CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)
  true
end