class ROM::Repository

A repository with a given name and adapter

@api private

Public Class Methods

build(name, uri, relations = {}) click to toggle source

Build a repository with a given name and uri

@param [Symbol] name

the repository's name

@param [Addressable::URI] uri

the uri for initializing the adapter

@return [Repository]

@api private

# File lib/rom/repository.rb, line 22
def self.build(name, uri, relations = {})
  new(name, Axiom::Adapter.build(uri), relations)
end

Public Instance Methods

[](name) click to toggle source

Return the relation identified by name

@example

repo = Repository.coerce(:test, 'in_memory://test')
repo.register(:foo, [[:id, String], [:foo, String]])
repo[:foo]

# => <Axiom::Relation header=Axiom::Header ...>

@param [Symbol] name

the name of the relation

@return [Axiom::Relation]

@raise [KeyError]

@api public

# File lib/rom/repository.rb, line 44
def [](name)
  relations.fetch(name)
end
[]=(name, relation) click to toggle source

Register a relation with this repository

@param [Axiom::Relation::Base] relation

@return [Object] relation gateway

@api public

# File lib/rom/repository.rb, line 55
def []=(name, relation)
  adapter[name]   = relation
  relations[name] = adapter[name]
end