Class: Database

Inherits:
FogModel show all
Defined in:
lib/dew/models/database.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FogModel

#id, #initialize, #method_missing, #wait_until_ready

Constructor Details

This class inherits a constructor from FogModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FogModel

Class Method Details

.create!(name, size, storage_size, password) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/dew/models/database.rb', line 3

def self.create!(name, size, storage_size, password)
  new Cloud.rds.servers.create(
            :engine => 'MySQL',
            :master_username => 'root',
            :password => password,
            :id => name,
            :allocated_storage => storage_size.to_s,
            :flavor_id => size
  )
end

.get(name) ⇒ Object



14
15
16
17
# File 'lib/dew/models/database.rb', line 14

def self.get name
  db = Cloud.rds.servers.get(name)
  new db if db
end

Instance Method Details

#db_environment_file(password) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/dew/models/database.rb', line 23

def db_environment_file password
  <<-EOF
DB_HOST=#{fog_object.endpoint['Address']}
DB_NAME=#{id}
DB_USERNAME=#{master_username}
DB_PASSWORD=#{password}
  EOF
end

#public_addressObject



19
20
21
# File 'lib/dew/models/database.rb', line 19

def public_address
  fog_object.endpoint['Address']
end