Class: Hanami::CLI::Commands::App::DB::Utils::DatabaseConfig Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/cli/commands/app/db/utils/database_config.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database_url) ⇒ DatabaseConfig

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DatabaseConfig.

Since:

  • 2.0.0



18
19
20
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 18

def initialize(database_url)
  @uri = URI(database_url)
end

Instance Attribute Details

#uriObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



15
16
17
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 15

def uri
  @uri
end

Instance Method Details

#db_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



46
47
48
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 46

def db_name
  @db_name ||= uri.path.gsub(/\A\//, "")
end

#db_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



51
52
53
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 51

def db_type
  uri.scheme
end

#hostnameObject Also known as: host

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



23
24
25
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 23

def hostname
  uri.hostname
end

#passwordObject Also known as: pass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



35
36
37
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 35

def password
  uri.password
end

#portObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



41
42
43
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 41

def port
  uri.port
end

#userObject Also known as: username

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



29
30
31
# File 'lib/hanami/cli/commands/app/db/utils/database_config.rb', line 29

def user
  uri.user
end