Sha256: 71f7ba8342db55aa569138063cb6e90976b69aec601eb487d3aa0a8aa128510a

Contents?: true

Size: 774 Bytes

Versions: 12

Compression:

Stored size: 774 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'
          PostgreSQLAdapter.new(database_url)
        when 'mongodb'
          MongoDBAdapter.new(database_url)
        else
          raise NotImplementedError
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pupa-0.1.11 lib/pupa/processor/connection.rb
pupa-0.1.10 lib/pupa/processor/connection.rb
pupa-0.1.9 lib/pupa/processor/connection.rb
pupa-0.1.8 lib/pupa/processor/connection.rb
pupa-0.1.7 lib/pupa/processor/connection.rb
pupa-0.1.6 lib/pupa/processor/connection.rb
pupa-0.1.5 lib/pupa/processor/connection.rb
pupa-0.1.4 lib/pupa/processor/connection.rb
pupa-0.1.3 lib/pupa/processor/connection.rb
pupa-0.1.2 lib/pupa/processor/connection.rb
pupa-0.1.1 lib/pupa/processor/connection.rb
pupa-0.1.0 lib/pupa/processor/connection.rb