Sha256: 9b1f1940617fb22baab6b4310c52bd2a98bd59392013c1e72cafb5745ca3ffb0

Contents?: true

Size: 784 Bytes

Versions: 5

Compression:

Stored size: 784 Bytes

Contents

require 'pupa/processor/connection_adapters/mongodb_adapter'
require 'pupa/processor/connection_adapters/postgresql_adapter'

module Pupa
  class Processor
    # A database system connection factory.
    class Connection
      # Returns a configured connection to a database system.
      #
      # See each connection adapter for more information.
      #
      # @param [String] database_url the database URL
      # @return a configured connection to a database system
      def self.new(database_url)
        case URI.parse(database_url).scheme
        when 'postgres', 'sqlite'
          PostgreSQLAdapter.new(database_url)
        when 'mongodb'
          MongoDBAdapter.new(database_url)
        else
          raise NotImplementedError
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pupa-0.2.4 lib/pupa/processor/connection.rb
pupa-0.2.3 lib/pupa/processor/connection.rb
pupa-0.2.2 lib/pupa/processor/connection.rb
pupa-0.2.1 lib/pupa/processor/connection.rb
pupa-0.2.0 lib/pupa/processor/connection.rb