Class: ROM::Repository Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/repository.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A repository with a given name and adapter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(name, uri, relations = {}) ⇒ Repository

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build a repository with a given name and uri

Parameters:

  • name (Symbol)

    the repository’s name

  • uri (Addressable::URI)

    the uri for initializing the adapter

Returns:



22
23
24
# File 'lib/rom/repository.rb', line 22

def self.build(name, uri, relations = {})
  new(name, Axiom::Adapter.build(uri), relations)
end

Instance Method Details

#[](name) ⇒ Axiom::Relation

Return the relation identified by name

Examples:


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

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

Parameters:

  • name (Symbol)

    the name of the relation

Returns:

  • (Axiom::Relation)

Raises:

  • (KeyError)


44
45
46
# File 'lib/rom/repository.rb', line 44

def [](name)
  relations.fetch(name)
end

#[]=(name, relation) ⇒ Object

Register a relation with this repository

Parameters:

  • relation (Axiom::Relation::Base)

Returns:

  • (Object)

    relation gateway



55
56
57
58
# File 'lib/rom/repository.rb', line 55

def []=(name, relation)
  adapter[name]   = relation
  relations[name] = adapter[name]
end