Sha256: 3c63ac527fe3f5f0f13e383d66db3337e09adecf33980b0bb3df08474a1d87d7
Contents?: true
Size: 1005 Bytes
Versions: 14
Compression:
Stored size: 1005 Bytes
Contents
module Neo4j module Core module GraphJSON def self.to_graph_json(objects) nodes = {} edges = {} objects.each do |object| case object when Neo4j::ActiveNode, Neo4j::Server::CypherNode nodes[object.neo_id] = { id: object.neo_id, labels: (object.is_a?(Neo4j::ActiveNode) ? [object.class.name] : object.labels), properties: object.attributes } when Neo4j::ActiveRel, Neo4j::Server::CypherRelationship edges[[object.start_node.neo_id, object.end_node.neo_id]] = { source: object.start_node.neo_id, target: object.end_node.neo_id, type: object.rel_type, properties: object.props } else fail "Invalid value found: #{object.inspect}" end end { nodes: nodes.values, edges: edges.values }.to_json end end end end
Version data entries
14 entries across 14 versions & 1 rubygems