Method: ROM::Environment.setup

Defined in:
lib/rom/environment.rb

.setup(config) ⇒ Environment

Build an environment instance from a repository config hash

Examples:


config = { 'test' => 'memory://test' }
env    = ROM::Environment.setup(config)

Parameters:

  • config (Environment, Hash<#to_sym, String>)

    an environment or a hash of adapter uri strings, keyed by repository name

Returns:



24
25
26
27
28
29
30
31
32
# File 'lib/rom/environment.rb', line 24

def self.setup(config)
  return config if config.kind_of?(self)

  repositories = config.each_with_object({}) { |(name, uri), hash|
    hash[name.to_sym] = Repository.build(name, Addressable::URI.parse(uri))
  }

  build(repositories)
end