# File lib/dm-core.rb, line 129
  def self.setup(name, uri_or_options)
    assert_kind_of 'name',           name,           Symbol
    assert_kind_of 'uri_or_options', uri_or_options, Addressable::URI, Hash, String

    case uri_or_options
      when Hash
        adapter_name = uri_or_options[:adapter].to_s
      when String, DataObjects::URI, Addressable::URI
        uri_or_options = DataObjects::URI.parse(uri_or_options) if uri_or_options.kind_of?(String)
        adapter_name = uri_or_options.scheme
    end

    class_name = Extlib::Inflection.classify(adapter_name) + 'Adapter'

    unless Adapters::const_defined?(class_name)
      lib_name = "#{Extlib::Inflection.underscore(adapter_name)}_adapter"
      begin
        require root / 'lib' / 'dm-core' / 'adapters' / lib_name
      rescue LoadError => e
        begin
          require lib_name
        rescue Exception
          # library not found, raise the original error
          raise e
        end
      end
    end

    Repository.adapters[name] = Adapters::const_get(class_name).new(name, uri_or_options)
  end