Class: ROM::Schema

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/rom/schema.rb,
lib/rom/schema/definition.rb,
lib/rom/schema/definition/relation.rb,
lib/rom/schema/definition/relation/base.rb

Overview

Schema builder DSL

Defined Under Namespace

Classes: Definition

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(repositories, &block) ⇒ Schema

Build a relation schema

Examples:


Schema.build do
  base_relation :users do
    repository :test
    attribute :id, :name
  end
end

Returns:



24
25
26
# File 'lib/rom/schema.rb', line 24

def self.build(repositories, &block)
  new(Definition.new(repositories, &block))
end

Instance Method Details

#[](name) ⇒ Axiom::Relation, Axiom::Relation::Base

Return defined relation identified by name

Examples:


schema[:users] # => #<Axiom::Relation::Base ..>

Returns:

  • (Axiom::Relation, Axiom::Relation::Base)


37
38
39
# File 'lib/rom/schema.rb', line 37

def [](name)
  definition[name]
end

#call(&block) ⇒ Object

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.



42
43
44
45
# File 'lib/rom/schema.rb', line 42

def call(&block)
  definition.instance_eval(&block)
  self
end