Class: ROM::Relation::ViewDSL
- Inherits:
-
Object
- Object
- ROM::Relation::ViewDSL
- Defined in:
- core/lib/rom/relation/view_dsl.rb
Overview
ViewDSL is exposed in Relation.view
method
This is used to establish pre-defined relation views with explicit schemas. Such views can be used to compose relations together, even from multiple adapters. In advanced adapters like rom-sql using view DSL is not required though, as relation schemas are dynamic and they always represent current tuple structure.
Instance Attribute Summary collapse
- #name ⇒ Object readonly
- #new_schema ⇒ Object readonly
- #relation_block ⇒ Object readonly
Instance Method Summary collapse
-
#relation(&block) ⇒ Proc
Define a relation block for a relation view.
-
#schema(&block) ⇒ Proc
Define a schema for a relation view.
Instance Attribute Details
#name ⇒ Object (readonly)
16 17 18 |
# File 'core/lib/rom/relation/view_dsl.rb', line 16 def name @name end |
#new_schema ⇒ Object (readonly)
24 25 26 |
# File 'core/lib/rom/relation/view_dsl.rb', line 24 def new_schema @new_schema end |
#relation_block ⇒ Object (readonly)
20 21 22 |
# File 'core/lib/rom/relation/view_dsl.rb', line 20 def relation_block @relation_block end |
Instance Method Details
#relation(&block) ⇒ Proc
Define a relation block for a relation view
53 54 55 |
# File 'core/lib/rom/relation/view_dsl.rb', line 53 def relation(&block) @relation_block = lambda(&block) end |
#schema(&block) ⇒ Proc
Define a schema for a relation view
42 43 44 |
# File 'core/lib/rom/relation/view_dsl.rb', line 42 def schema(&block) @new_schema = -> relations { @schema.with(relations: relations).instance_exec(&block) } end |