Class: Pgchief::Command::DatabasePrivilegesGrant

Inherits:
Base
  • Object
show all
Defined in:
lib/pgchief/command/database_privileges_grant.rb

Overview

Class to grant database privileges

Instance Attribute Summary collapse

Attributes inherited from Base

#conn, #params

Instance Method Summary collapse

Methods inherited from Base

call

Constructor Details

#initialize(*params) ⇒ DatabasePrivilegesGrant

Returns a new instance of DatabasePrivilegesGrant.



9
10
11
12
13
# File 'lib/pgchief/command/database_privileges_grant.rb', line 9

def initialize(*params)
  @username = params[0]
  @password = params[1]
  @databases = params[2]
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



7
8
9
# File 'lib/pgchief/command/database_privileges_grant.rb', line 7

def database
  @database
end

#passwordObject (readonly)

Returns the value of attribute password.



7
8
9
# File 'lib/pgchief/command/database_privileges_grant.rb', line 7

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/pgchief/command/database_privileges_grant.rb', line 7

def username
  @username
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
# File 'lib/pgchief/command/database_privileges_grant.rb', line 15

def call
  @databases.each do |database|
    @database = database
    grant_privs!
    store_credentials!
  end

  "Privileges granted to #{username} on #{@databases.join(', ')}"
end