Class: Neo4j::Http::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/http/results.rb

Class Method Summary collapse

Class Method Details

.parse(results) ⇒ Object

Example result set: [href=""n"">columns”=>, “data”=> [{“row”=>[{“name”=>“Foo”, “uuid”=>“8c7dcfda-d848-4937-a91a-2e6debad2dd6”],

"meta"=>[{"id"=>242, "type"=>"node", "deleted"=>false}]}]}]


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/neo4j/http/results.rb', line 12

def self.parse(results)
  columns = results["columns"]
  data = results["data"]

  data.map do |result|
    row = result["row"] || []
    meta = result["meta"] || []
    compacted_data = row.each_with_index.map do |attributes, index|
      row_meta = meta[index] || {}
      attributes["_neo4j_meta_data"] = row_meta if attributes.is_a?(Hash)
      attributes
    end

    columns.zip(compacted_data).to_h.with_indifferent_access
  end
end