Class: HP::Cloud::DatabaseHelper
- Inherits:
-
BaseHelper
- Object
- BaseHelper
- HP::Cloud::DatabaseHelper
- Defined in:
- lib/hpcloud/database_helper.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
-
#status ⇒ Object
Returns the value of attribute status.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from BaseHelper
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(connection, foggy = nil) ⇒ DatabaseHelper
constructor
A new instance of DatabaseHelper.
- #save ⇒ Object
Methods inherited from BaseHelper
#destroy, #is_valid?, #set_error, #to_hash
Constructor Details
#initialize(connection, foggy = nil) ⇒ DatabaseHelper
Returns a new instance of DatabaseHelper.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hpcloud/database_helper.rb', line 32 def initialize(connection, foggy = nil) super(connection, foggy) if foggy.nil? @meta = HP::Cloud::Metadata.new(nil) return end @id = foggy.id @name = foggy.name @size = foggy.size @type = foggy.type @status = foggy.status @meta = HP::Cloud::Metadata.new(foggy.) end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
25 26 27 |
# File 'lib/hpcloud/database_helper.rb', line 25 def id @id end |
#meta ⇒ Object
Returns the value of attribute meta.
26 27 28 |
# File 'lib/hpcloud/database_helper.rb', line 26 def @meta end |
#name ⇒ Object
Returns the value of attribute name.
25 26 27 |
# File 'lib/hpcloud/database_helper.rb', line 25 def name @name end |
#size ⇒ Object
Returns the value of attribute size.
25 26 27 |
# File 'lib/hpcloud/database_helper.rb', line 25 def size @size end |
#status ⇒ Object
Returns the value of attribute status.
25 26 27 |
# File 'lib/hpcloud/database_helper.rb', line 25 def status @status end |
#type ⇒ Object
Returns the value of attribute type.
25 26 27 |
# File 'lib/hpcloud/database_helper.rb', line 25 def type @type end |
Class Method Details
.get_keys ⇒ Object
28 29 30 |
# File 'lib/hpcloud/database_helper.rb', line 28 def self.get_keys() return [ "id", "name", "size", "type", "status" ] end |
Instance Method Details
#save ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hpcloud/database_helper.rb', line 46 def save if is_valid? set_error(@meta.cstatus) end return false if is_valid? == false if @fog.nil? hsh = {:name => @name, :description => @description, :size => @size, :metadata => @meta.hsh} database = @connection.block.databases.create(hsh) if database.nil? set_error("Error creating database '#{@name}'") return false end @id = database.id @fog = database return true else raise "Update not implemented" end end |