Class: ROM::Relation::Graph

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Includes:
Memoizable, Pipeline, Pipeline::Proxy, Materializable
Defined in:
lib/rom/relation/graph.rb,
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



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

param :nodes

#rootRelation (readonly) Also known as: left

Returns The root relation.

Returns:



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

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


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

def graph?
  true
end

#map_to(klass) ⇒ Graph

Map graph tuples to custom objects

Returns:

See Also:



78
79
80
# File '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 '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

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



85
86
87
# File 'lib/rom/relation/graph.rb', line 85

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:



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

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