Class: Hugo::Database

Inherits:
Object
  • Object
show all
Includes:
Mixin::ParamsValidate, Singleton
Defined in:
lib/hugo/database.rb

Constant Summary collapse

DEFAULT_SERVER =
"DEFAULT"
DEFAULT_SIZE =
5
DEFAULT_ZONE =
'us-east-1c'

Instance Method Summary collapse

Methods included from Mixin::ParamsValidate

#set_or_return, #validate

Constructor Details

#initializeDatabase

Returns a new instance of Database.



12
13
14
15
16
17
# File 'lib/hugo/database.rb', line 12

def initialize
  size DEFAULT_SIZE
  zone DEFAULT_ZONE
  server DEFAULT_SERVER
  db_security_group "default"
end

Instance Method Details

#db_security_group(arg = nil) ⇒ Object



54
55
56
# File 'lib/hugo/database.rb', line 54

def db_security_group(arg=nil)
  set_or_return(:db_security_group, arg, :kind_of => [String])     
end

#deployObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/hugo/database.rb', line 19

def deploy
  Hugo::Aws::Rds.find_or_create( :name => name,
                            :server => server,
                            :user => user,
                            :password => password,
                            :size => size,
                            :zone => zone,
                            :db_security_group => db_security_group
                             )
end

#name(arg = nil) ⇒ Object



30
31
32
# File 'lib/hugo/database.rb', line 30

def name(arg=nil)
  set_or_return(:name, arg, :kind_of => [String])     
end

#password(arg = nil) ⇒ Object



42
43
44
# File 'lib/hugo/database.rb', line 42

def password(arg=nil)
  set_or_return(:password, arg, :kind_of => [String])     
end

#server(arg = nil) ⇒ Object



34
35
36
# File 'lib/hugo/database.rb', line 34

def server(arg=nil)
  set_or_return(:server, arg, :kind_of => [String])     
end

#size(arg = nil) ⇒ Object



46
47
48
# File 'lib/hugo/database.rb', line 46

def size(arg=nil)
  set_or_return(:size, arg, :kind_of => [Integer])     
end

#user(arg = nil) ⇒ Object



38
39
40
# File 'lib/hugo/database.rb', line 38

def user(arg=nil)
  set_or_return(:user, arg, :kind_of => [String])     
end

#zone(arg = nil) ⇒ Object



50
51
52
# File 'lib/hugo/database.rb', line 50

def zone(arg=nil)
  set_or_return(:zone, arg, :kind_of => [String])     
end