Skip to content

Commit

Permalink
finally fixed that all paths bug
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Feb 28, 2013
1 parent d4bc286 commit b31f829
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/neography/path_traverser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def initialize(from, to, algorithm, all=false, types = nil, dir = "all" )
@relationships << {"type" => type.to_s, "direction" => dir.to_s }
end unless types.nil?
@get = ["node","rel"]
@loaded = Array.new
@loaded_nodes = Array.new
@loaded_rels = Array.new
end

def nodes
Expand Down Expand Up @@ -62,15 +63,15 @@ def each

if @get.include?("node")
path["nodes"].each_with_index do |n, i|
@loaded[n.split('/').last.to_i] = Neography::Node.load(n) if @loaded.at(n.split('/').last.to_i).nil?
paths[i * 2] = @loaded[n.split('/').last.to_i]
@loaded_nodes[n.split('/').last.to_i] = Neography::Node.load(n) if @loaded_nodes.at(n.split('/').last.to_i).nil?
paths[i * 2] = @loaded_nodes[n.split('/').last.to_i]
end
end

if @get.include?("rel")
path["relationships"].each_with_index do |r, i|
@loaded[r.split('/').last.to_i] = Neography::Relationship.load(r) if @loaded.at(r.split('/').last.to_i).nil?
paths[i * 2 + 1] = @loaded[r.split('/').last.to_i]
@loaded_rels[r.split('/').last.to_i] = Neography::Relationship.load(r) if @loaded_rels.at(r.split('/').last.to_i).nil?
paths[i * 2 + 1] = @loaded_rels[r.split('/').last.to_i]
end
end

Expand Down

0 comments on commit b31f829

Please sign in to comment.