Class: ROM::Schema::Definition
- Inherits:
-
Object
- Object
- ROM::Schema::Definition
- Defined in:
- lib/rom/schema/definition.rb,
lib/rom/schema/definition/relation.rb,
lib/rom/schema/definition/relation/base.rb
Overview
Builder object used by schema DSL to establish Axiom relations
Defined Under Namespace
Classes: Relation
Instance Attribute Summary collapse
-
#relations ⇒ Object
readonly
Returns the value of attribute relations.
-
#repositories ⇒ Object
readonly
Returns the value of attribute repositories.
Instance Method Summary collapse
-
#[](name) ⇒ Axiom::Relation, Axiom::Relation::Base
private
Return relation identified by name.
-
#base_relation(name, &block) ⇒ Definition
private
Build a base relation.
-
#initialize(repositories, &block) ⇒ Definition
constructor
private
A new instance of Definition.
-
#relation(name, &block) ⇒ Definition
private
Build a relation.
Constructor Details
#initialize(repositories, &block) ⇒ Definition
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.
Returns a new instance of Definition.
15 16 17 18 19 |
# File 'lib/rom/schema/definition.rb', line 15 def initialize(repositories, &block) @repositories = repositories @relations = {} instance_eval(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Axiom::Relation, Axiom::Relation::Base (private)
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.
Method missing hook
75 76 77 |
# File 'lib/rom/schema/definition.rb', line 75 def method_missing(name) self[name] || super end |
Instance Attribute Details
#relations ⇒ Object (readonly)
Returns the value of attribute relations.
12 13 14 |
# File 'lib/rom/schema/definition.rb', line 12 def relations @relations end |
#repositories ⇒ Object (readonly)
Returns the value of attribute repositories.
12 13 14 |
# File 'lib/rom/schema/definition.rb', line 12 def repositories @repositories end |
Instance Method Details
#[](name) ⇒ Axiom::Relation, Axiom::Relation::Base
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.
Return relation identified by name
64 65 66 |
# File 'lib/rom/schema/definition.rb', line 64 def [](name) relations[name] end |
#base_relation(name, &block) ⇒ Definition
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 base relation
34 35 36 37 38 39 40 |
# File 'lib/rom/schema/definition.rb', line 34 def base_relation(name, &block) builder = Relation::Base.new(&block) repository = repositories.fetch(builder.repository) repository[name] = builder.call(name) relations[name] = repository[name] end |
#relation(name, &block) ⇒ Definition
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 relation
55 56 57 |
# File 'lib/rom/schema/definition.rb', line 55 def relation(name, &block) relations[name] = instance_eval(&block) end |