Class: Pgchief::Command::UserCreate
- Defined in:
- lib/pgchief/command/user_create.rb
Overview
Class to create a user
Constant Summary collapse
- USER_OPTIONS =
%w[ NOINHERIT NOCREATEDB NOCREATEROLE NOSUPERUSER NOREPLICATION ].freeze
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Pgchief::Command::Base
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
15 16 17 |
# File 'lib/pgchief/command/user_create.rb', line 15 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
15 16 17 |
# File 'lib/pgchief/command/user_create.rb', line 15 def username @username end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pgchief/command/user_create.rb', line 17 def call @username, @password = params raise Pgchief::Errors::UserExistsError if user_exists? create_user! save_credentials! "User '#{username}' created successfully!" rescue PG::Error => e "Error: #{e.}" ensure conn.close end |