Class: ROM::Relation::Graph

Inherits:
Object
  • Object
show all
Includes:
Materializable
Defined in:
core/lib/rom/relation/graph.rb,
changeset/lib/rom/changeset/extensions/relation.rb

Overview

Changeset extenions for combined relations

Direct Known Subclasses

Combined, Wrap

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROM::Pipeline::Proxy

Instance Attribute Details

#nodesArray<Relation> (readonly) Also known as: right

Returns An array with relation nodes.

Returns:

  • (Array<Relation>)

    An array with relation nodes



29
# File 'core/lib/rom/relation/graph.rb', line 29

param :nodes

#rootRelation (readonly) Also known as: left

Returns The root relation.

Returns:



25
# File 'core/lib/rom/relation/graph.rb', line 25

param :root

Instance Method Details

#changesetObject

Build a changeset for a combined relation

Raises:

  • NotImplementedError



20
21
22
# File 'changeset/lib/rom/changeset/extensions/relation.rb', line 20

def changeset(*)
  raise NotImplementedError, "Changeset doesn't support combined relations yet"
end

#each {|Hash, Object| ... } ⇒ Object Originally defined in module Materializable

Yield relation tuples

Yields:

  • (Hash, Object)

#firstObject Originally defined in module Materializable

Return first tuple from a relation coerced to an array

Returns:

  • (Object)

#map_to(klass) ⇒ Graph

Map graph tuples to custom objects

Returns:

See Also:



78
79
80
# File 'core/lib/rom/relation/graph.rb', line 78

def map_to(klass)
  self.class.new(root.map_to(klass), nodes)
end

#map_with(*names, **opts) ⇒ Relation::Composite

Map graph tuples via custom mappers



67
68
69
# File 'core/lib/rom/relation/graph.rb', line 67

def map_with(*names, **opts)
  names.reduce(self.class.new(root.with(opts), nodes)) { |a, e| a >> mappers[e] }
end

#oneObject Originally defined in module Materializable

Delegate to loaded relation and return one object

Returns:

  • (Object)

See Also:

#one!Object Originally defined in module Materializable

Delegate to loaded relation and return one object

Returns:

  • (Object)

See Also:

#to_aArray Also known as: to_ary Originally defined in module Materializable

Coerce the relation to an array

Returns:

  • (Array)

#with_nodes(nodes) ⇒ Graph

Rebuild a graph with new nodes

Parameters:

Returns:



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

def with_nodes(nodes)
  self.class.new(root, nodes)
end