Sha256: d34caf00aa6d21df15400368ea2ef24f12f8d52f2221b381b46cb6ae24cc28be

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require_relative "abstract"

module Hanami
  module Model
    module Sql
      module Consoles
        # MySQL adapter
        #
        # @since 0.7.0
        # @api private
        class Mysql < Abstract
          # @since 0.7.0
          # @api private
          COMMAND = "mysql"

          # @since 0.7.0
          # @api private
          def connection_string
            concat(command, host, database, port, username, password)
          end

          private

          # @since 0.7.0
          # @api private
          def command
            COMMAND
          end

          # @since 0.7.0
          # @api private
          def host
            " -h #{@uri.host}"
          end

          # @since 0.7.0
          # @api private
          def database
            " -D #{database_name}"
          end

          # @since 0.7.0
          # @api private
          def port
            " -P #{@uri.port}" unless @uri.port.nil?
          end

          # @since 0.7.0
          # @api private
          def username
            " -u #{@uri.user}" unless @uri.user.nil?
          end

          # @since 0.7.0
          # @api private
          def password
            " -p #{@uri.password}" unless @uri.password.nil?
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-model-1.3.3 lib/hanami/model/sql/consoles/mysql.rb