Module: ROM::Relation::Materializable
- Included in:
- ROM::Relation, Composite, Curried, Graph
- Defined in:
- core/lib/rom/relation/materializable.rb
Overview
Interface for objects that can be materialized into a loaded relation
Instance Method Summary collapse
-
#each {|Hash, Object| ... } ⇒ Object
Yield relation tuples.
-
#first ⇒ Object
Return first tuple from a relation coerced to an array.
-
#one ⇒ Object
Delegate to loaded relation and return one object.
-
#one! ⇒ Object
Delegate to loaded relation and return one object.
-
#to_a ⇒ Array
(also: #to_ary)
Coerce the relation to an array.
Instance Method Details
#each {|Hash, Object| ... } ⇒ Object
Yield relation tuples
24 25 26 27 28 |
# File 'core/lib/rom/relation/materializable.rb', line 24 def each return to_enum unless block_given? to_a.each { |tuple| yield(tuple) } end |
#first ⇒ Object
Return first tuple from a relation coerced to an array
57 58 59 |
# File 'core/lib/rom/relation/materializable.rb', line 57 def first to_a.first end |
#one ⇒ Object
Delegate to loaded relation and return one object
37 38 39 |
# File 'core/lib/rom/relation/materializable.rb', line 37 def one call.one end |
#one! ⇒ Object
Delegate to loaded relation and return one object
48 49 50 |
# File 'core/lib/rom/relation/materializable.rb', line 48 def one! call.one! end |
#to_a ⇒ Array Also known as: to_ary
Coerce the relation to an array
14 15 16 |
# File 'core/lib/rom/relation/materializable.rb', line 14 def to_a call.to_a end |