Sha256: 1d8e3bb18086dc3979a2b8969057d2188ad40276f333c162529b39ad11744166

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

require 'uri'

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

        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

1 entries across 1 versions & 1 rubygems

Version Path
hanami-model-1.0.0.beta2 lib/hanami/model/sql/console.rb