Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
uoy-faculty-spec-helpers / lib / faculty / database_helper / admin_connection.rb
Size: Mime:
# frozen_string_literal: true

require 'singleton'

module Faculty
  module DatabaseHelper
    # Set up a connection to the database as 'postgres' with full admin access
    module AdminConnection
      # Create a connection to the DB as a singleton
      class Connection
        include Singleton

        def connection
          @connection ||= Sequel.connect(
            adapter: 'postgres',
            host: ENV.fetch('DB_HOST', nil),
            database: 'faculty',
            user: 'postgres',
            search_path: 'groupmanager,rbac'
          )
        end
      end

      def connection
        Connection.instance.connection
      end
    end
  end
end