Class: Neo4j::Cypher::ResultWrapper
- Inherits:
-
Object
- Object
- Neo4j::Cypher::ResultWrapper
- Includes:
- Enumerable
- Defined in:
- lib/neo4j-cypher/result_wrapper.rb
Overview
Wraps the Cypher query result. Loads the node and relationships wrapper if possible and use symbol as column keys. This is typically used in the native neo4j bindings since result does is not a Ruby enumerable with symbols as keys.
Defined Under Namespace
Classes: ResultsAlreadyConsumedException
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
The original result from the Neo4j Cypher Engine, once forward read only !.
Instance Method Summary collapse
-
#columns ⇒ Array<Symbol>
The columns in the query result.
-
#each ⇒ Object
for the Enumerable contract.
-
#initialize(source) ⇒ ResultWrapper
constructor
A new instance of ResultWrapper.
Constructor Details
#initialize(source) ⇒ ResultWrapper
Returns a new instance of ResultWrapper.
23 24 25 26 |
# File 'lib/neo4j-cypher/result_wrapper.rb', line 23 def initialize(source) @source = source @unread = true end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the original result from the Neo4j Cypher Engine, once forward read only !.
21 22 23 |
# File 'lib/neo4j-cypher/result_wrapper.rb', line 21 def source @source end |
Instance Method Details
#columns ⇒ Array<Symbol>
Returns the columns in the query result.
29 30 31 |
# File 'lib/neo4j-cypher/result_wrapper.rb', line 29 def columns @source.columns.map { |x| x.to_sym } end |
#each ⇒ Object
for the Enumerable contract
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/neo4j-cypher/result_wrapper.rb', line 34 def each raise ResultsAlreadyConsumedException unless @unread if block_given? @unread = false @source.each { |row| yield symbolize_row_keys(row) } else Enumerator.new(self) end end |