Class: CloudDB::Database
- Inherits:
-
Object
- Object
- CloudDB::Database
- Defined in:
- lib/clouddb/database.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#destroy! ⇒ Object
Deletes the current Database object and removes it from the instance.
-
#initialize(instance, name) ⇒ Database
constructor
Creates a new CloudDB::Database object representing a database.
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
#name ⇒ Object (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 |