Class: Neo4j::Core::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/neo4j/support/core_ext.rb

Overview

DSL for generating Cypher queries and enumerating their results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sessionNeo4j::Session (readonly)

Exports the underlying session handle.

Returns:

  • (Neo4j::Session)


12
13
14
# File 'lib/rom/neo4j/support/core_ext.rb', line 12

def session
  @session
end

Instance Method Details

#eachObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rom/neo4j/support/core_ext.rb', line 14

def each
  return enum_for(:each) unless block_given?

  response = self.response
  columns = response.columns.map { |c| c.to_sym }

  if response.is_a?(Neo4j::Server::CypherResponse)
    response.data.map do |row|
      yield Hash[columns.zip(row)]
    end
  else
    raise Neo4j::Core::UnsupportedDriver, 'Neo4j::Embedded is not supported (yet)'
  end
end