Class: Pgchief::Prompt::GrantDatabasePrivileges

Inherits:
Base
  • Object
show all
Defined in:
lib/pgchief/prompt/grant_database_privileges.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

#ask_for_passwordObject



21
22
23
# File 'lib/pgchief/prompt/grant_database_privileges.rb', line 21

def ask_for_password
  prompt.mask('Password:')
end

#callObject



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

def call
  username  = params[0] || select_user
  password  = params[1] || ask_for_password
  databases = params[2] || prompt.multi_select("Give \"#{username}\" access to database(s):",
                                               Pgchief::Database.all)

  result = Pgchief::Command::DatabasePrivilegesGrant.call(username, password, databases)
  prompt.say result
end

#select_userObject



17
18
19
# File 'lib/pgchief/prompt/grant_database_privileges.rb', line 17

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