Sha256: 3a720ef0d16bfc45c923e5723fe9044eaef98a288b4caf811bf250b32d9989f7

Contents?: true

Size: 511 Bytes

Versions: 3

Compression:

Stored size: 511 Bytes

Contents

require "singleton"

module Snowglobe
  class DatabaseConfigurationRegistry
    include Singleton

    def initialize
      @registry = {}
    end

    def register(config_class)
      registry[config_class.name] = config_class
    end

    def get(name)
      registry.fetch(name) do
        raise KeyError, "No such adapter registered: #{name}"
      end
    end

    protected

    attr_reader :registry
  end
end

require_relative "database_adapters/postgresql"
require_relative "database_adapters/sqlite3"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
snowglobe-0.3.0 lib/snowglobe/database_configuration_registry.rb
snowglobe-0.2.0 lib/snowglobe/database_configuration_registry.rb
snowglobe-0.1.0 lib/snowglobe/database_configuration_registry.rb