Class: Pgchief::Prompt::ViewDatabaseConnectionString

Inherits:
Base
  • Object
show all
Defined in:
lib/pgchief/prompt/view_database_connection_string.rb

Overview

Class to ask for database names, in order to create it

Instance Attribute Summary

Attributes inherited from Base

#params

Instance Method Summary collapse

Methods inherited from Base

call, #initialize, #klassify, #prompt, #yes_or_no

Constructor Details

This class inherits a constructor from Pgchief::Prompt::Base

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
# File 'lib/pgchief/prompt/view_database_connection_string.rb', line 7

def call
  username = params.first || select_user
  database = prompt.select("Database you're connecting to:", Pgchief::Database.all + ['None'])
  database = nil if database == 'None'
  result   = Pgchief::Command::RetrieveConnectionString.call(username, database)

  prompt.say result
end

#select_userObject



16
17
18
# File 'lib/pgchief/prompt/view_database_connection_string.rb', line 16

def select_user
  prompt.select('Select user to update:', Pgchief::User.all)
end