Sha256: ede9c06d76331e19e74ff189094e2615c66ae1ac017789aecd615aa4cfaa794c

Contents?: true

Size: 997 Bytes

Versions: 21

Compression:

Stored size: 997 Bytes

Contents

require 'uri'

module Hanami
  module Model
    module Sql
      # SQL console
      #
      # @since 0.7.0
      # @api private
      class Console
        extend Forwardable

        # @since 0.7.0
        # @api private
        def_delegator :console, :connection_string

        # @since 0.7.0
        # @api private
        def initialize(uri)
          @uri = URI.parse(uri)
        end

        private

        # @since 0.7.0
        # @api private
        def console # rubocop:disable Metrics/MethodLength
          case @uri.scheme
          when 'sqlite'
            require 'hanami/model/sql/consoles/sqlite'
            Sql::Consoles::Sqlite.new(@uri)
          when 'postgres', 'postgresql'
            require 'hanami/model/sql/consoles/postgresql'
            Sql::Consoles::Postgresql.new(@uri)
          when 'mysql', 'mysql2'
            require 'hanami/model/sql/consoles/mysql'
            Sql::Consoles::Mysql.new(@uri)
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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