Class: ROM::Relation::Graph

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Includes:
Memoizable, Pipeline, Pipeline::Proxy, 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

#__memoized__Object (readonly) Originally defined in module Memoizable

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.

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

Returns An array with relation nodes.

Returns:

  • (Array<Relation>)

    An array with relation nodes



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

param :nodes

#rootRelation (readonly) Also known as: left

Returns The root relation.

Returns:



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

param :root

Instance Method Details

#>>(other) ⇒ Relation::Composite Originally defined in module Pipeline::Operator

Compose two relation with a left-to-right composition

Examples:

users.by_name('Jane') >> tasks.for_users

Parameters:

  • other (Relation)

    The right relation

Returns:

#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)

#graph?true

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 if this is a graph relation

Returns:

  • (true)


54
55
56
# File 'core/lib/rom/relation/graph.rb', line 54

def graph?
  true
end

#map_to(klass) ⇒ Graph

Map graph tuples to custom objects

Returns:

See Also:



76
77
78
# File 'core/lib/rom/relation/graph.rb', line 76

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



65
66
67
# File 'core/lib/rom/relation/graph.rb', line 65

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

#mapperObject

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.



83
84
85
# File 'core/lib/rom/relation/graph.rb', line 83

def mapper
  mappers[to_ast]
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:

#respond_to_missing?(name, include_private = false) ⇒ Boolean Originally defined in module Pipeline::Proxy

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:

  • (Boolean)

#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:



45
46
47
# File 'core/lib/rom/relation/graph.rb', line 45

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