class CloudDB::Database

Attributes

name[R]

Public Class Methods

new(instance, name) click to toggle source

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

# 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

Public Instance Methods

destroy!() click to toggle source

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

# 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(%r^20.$/)
  true
end