Class: Graphable::ViaEdgeCreator
Instance Method Summary
collapse
Methods inherited from EdgeCreator
#initialize, through, via
Instance Method Details
#call ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/graphable/edge_creator.rb', line 86
def call
return if Graphable.has_completed_edge?(@source, @target, @name)
puts "Building #{@name} edges for #{@source.name} -> #{@target.name}"
sources.each_slice(250) do |slice|
Graphable.neo.batch(*slice.map { |obj|
source_node = load_node(obj)
relationships = []
targets_for(obj).each do |target|
metadata = {}
metadata = @metadata_proc.call(target) if @metadata_proc
target_node = load_node(target) rescue binding.pry
next unless source_node && target_node
relationships << [:create_relationship, @name, source_node, target_node, metadata]
end
relationships
}.flatten(1))
end
Graphable.completed_edge(@source, @target, @name)
end
|
#targets_for(source) ⇒ Object
108
109
110
111
112
|
# File 'lib/graphable/edge_creator.rb', line 108
def targets_for(source)
res = source.send(@method)
res = res.to_a if res.respond_to?(:to_a)
if res.respond_to?(:each) then res else [res] end
end
|