Sha256: fbb6056952c41265466115e83760eed0ea8145cf2649138ba87f4a3d646880ea

Contents?: true

Size: 1.26 KB

Versions: 24

Compression:

Stored size: 1.26 KB

Contents

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'.freeze

          # @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

24 entries across 24 versions & 1 rubygems

Version Path
hanami-model-1.3.2 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.3.1 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.3.0 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.3.0.beta1 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.2.0 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.2.0.rc2 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.2.0.rc1 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.2.0.beta2 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.2.0.beta1 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.1.0 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.1.0.rc1 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.0.4 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.0.3 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.1.0.beta3 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.1.0.beta2 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.1.0.beta1 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.0.2 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.0.1 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.0.0 lib/hanami/model/sql/consoles/mysql.rb
hanami-model-1.0.0.rc1 lib/hanami/model/sql/consoles/mysql.rb