class Orchestrate::Graph::RelationStem::Traversal
Traverses from a single node in the graph across one or more edges. The workhorse for gathering results from a graph search.
Attributes
edges[RW]
The graph types and depth to traverse. @return [Array<#to_s>]
kv_item[RW]
The KeyValue
item from which the graph query originates. @return [KeyValue]
Public Class Methods
new(kv_item, edge_names)
click to toggle source
Public Instance Methods
[](edge)
click to toggle source
Add a new type to the depth of the graph query. @param edge [#to_s] The type of relation to traverse. @return [Traversal]
# File lib/orchestrate/graph.rb, line 128 def [](edge) self.class.new(kv_item, [edges, edge].flatten) end
each() { |from_listing| ... }
click to toggle source
[Retrieves the related items](orchestrate.io/api/graph), and iterates over each item in the result. Used as the basis for Enumerable methods.
# File lib/orchestrate/graph.rb, line 137 def each(&block) @response ||= kv_item.perform(:get_relations, *edges) return enum_for(:each) unless block raise ResultsNotReady if kv_item.collection.app.inside_parallel? @response.results.each do |listing| listing_collection = kv_item.collection.app[listing['path']['collection']] yield KeyValue.from_listing(listing_collection, listing, @response) end @response = nil end