Class: Ghaki::Account::Database

Inherits:
Base
  • Object
show all
Includes:
DB_Connect, DB_Driver, DB_Name, DB_Port
Defined in:
lib/ghaki/account/database.rb

Constant Summary

Constants included from Password

Password::ASK_PASSWORD_RETRY_MAX

Constants included from Username

Username::USERNAME_RETRY_MAX

Constants included from Hostname

Hostname::HOSTNAME_RETRY_MAX

Instance Attribute Summary

Attributes included from DB_Connect

#db_connect

Attributes included from DB_Driver

#db_driver

Attributes included from DB_Port

#db_port

Attributes included from DB_Name

#db_name

Attributes included from EMailAddress

#email_address

Attributes included from Username

#username

Attributes included from Hostname

#hostname

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DB_Connect

#valid_db_connect?

Methods included from SynOpts

#attr_syn_opts

Methods included from DB_Driver

#valid_db_driver?

Methods included from DB_Port

#valid_db_port?

Methods included from DB_Name

#valid_db_name?

Methods inherited from Base

#ask_all, #collapse_opts, #initialize

Methods included from Password

#ask_password, #fail_password, #failed_passwords?, #opt_password, #password, #passwords, #passwords=, #reset_passwords, #retry_password?, #valid_password?

Methods included from Username

#ask_username, get_env, #valid_username?

Methods included from Hostname

#ask_hostname, get_env, #valid_hostname?

Constructor Details

This class inherits a constructor from Ghaki::Account::Base

Class Method Details

.from_opts(opts) ⇒ Object




21
22
23
# File 'lib/ghaki/account/database.rb', line 21

def self.from_opts opts
  opts[:account] || Database.new(opts)
end

.purge_opts(opts) ⇒ Object




26
27
28
29
30
31
32
# File 'lib/ghaki/account/database.rb', line 26

def self.purge_opts opts ; super opts
  DB_Name.purge_opts opts
  DB_Port.purge_opts opts
  DB_Driver.purge_opts opts
  DB_Connect.purge_opts opts
  opts
end

Instance Method Details

#expand_opts(opts = {}) ⇒ Object




39
40
41
42
43
44
45
# File 'lib/ghaki/account/database.rb', line 39

def expand_opts opts={} ; super opts
  opts[:db_name]    = @db_name    unless @db_name.nil?
  opts[:db_port]    = @db_port    unless @db_port.nil?
  opts[:db_driver]  = @db_driver  unless @db_driver.nil?
  opts[:db_connect] = @db_connect unless @db_connect.nil?
  opts
end

#to_sObject




48
49
50
# File 'lib/ghaki/account/database.rb', line 48

def to_s
  @db_name + ':' + (@username || '*') + '@' + (@hostname || 'localhost')
end