Module: ROM::Relation::Materializable

Included in:
ROM::Relation, Composite, Curried, Graph
Defined in:
lib/rom/relation/materializable.rb

Overview

Interface for objects that can be materialized into a loaded relation

Instance Method Summary collapse

Instance Method Details

#each {|Hash, Object| ... } ⇒ Object

Yield relation tuples

Yields:

  • (Hash, Object)


24
25
26
27
# File 'lib/rom/relation/materializable.rb', line 24

def each
  return to_enum unless block_given?
  to_a.each { |tuple| yield(tuple) }
end

#firstObject

Return first tuple from a relation coerced to an array

Returns:

  • (Object)


56
57
58
# File 'lib/rom/relation/materializable.rb', line 56

def first
  to_a.first
end

#oneObject

Delegate to loaded relation and return one object

Returns:

  • (Object)

See Also:



36
37
38
# File 'lib/rom/relation/materializable.rb', line 36

def one
  call.one
end

#one!Object

Delegate to loaded relation and return one object

Returns:

  • (Object)

See Also:



47
48
49
# File 'lib/rom/relation/materializable.rb', line 47

def one!
  call.one!
end

#to_aArray Also known as: to_ary

Coerce the relation to an array

Returns:

  • (Array)


14
15
16
# File 'lib/rom/relation/materializable.rb', line 14

def to_a
  call.to_a
end