Method: DataMapper.setup

Defined in:
lib/dm-core.rb

.setup(*args) ⇒ DataMapper::Adapters::AbstractAdapter

Setups up a connection to a data-store

Parameters:

  • name (Symbol)

    a name for the context, defaults to :default

  • uri_or_options (Hash(Symbol => String), Addressable::URI, String)

    connection information

Returns:

Raises:

  • (ArgumentError)

    name must be a Symbol, but was…” indicates that an invalid argument was passed for name

  • (ArgumentError)

    uri_or_options must be a Hash, URI or String, but was…” indicates that connection information could not be gleaned from the given uri_or_options[Hash, Addressable::URI, String]



226
227
228
229
230
231
232
233
234
# File 'lib/dm-core.rb', line 226

def self.setup(*args)
  adapter = args.first

  unless adapter.kind_of?(Adapters::AbstractAdapter)
    adapter = Adapters.new(*args)
  end

  Repository.adapters[adapter.name] = adapter
end