Class: Neo4j::Core::CypherSession::Responses::Bolt

Inherits:
Base
  • Object
show all
Defined in:
lib/neo4j/core/cypher_session/responses/bolt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#each

Constructor Details

#initialize(queries, flush_messages_proc, options = {}) ⇒ Bolt

Returns a new instance of Bolt.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/neo4j/core/cypher_session/responses/bolt.rb', line 11

def initialize(queries, flush_messages_proc, options = {})
  @wrap_level = options[:wrap_level] || Neo4j::Core::Config.wrapping_level

  @results = queries.map do
    fields, result_messages, _footer_messages = extract_message_groups(flush_messages_proc)
    # @result_info = footer_messages[0].args[0]

    data = result_messages.map do |result_message|
      validate_message_type!(result_message, :record)

      result_message.args[0]
    end

    result_from_data(fields, data)
  end
end

Instance Attribute Details

#result_infoObject (readonly)

Returns the value of attribute result_info.



9
10
11
# File 'lib/neo4j/core/cypher_session/responses/bolt.rb', line 9

def result_info
  @result_info
end

#resultsObject (readonly)

Returns the value of attribute results.



9
10
11
# File 'lib/neo4j/core/cypher_session/responses/bolt.rb', line 9

def results
  @results
end

Instance Method Details

#result_from_data(columns, entities_data) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/neo4j/core/cypher_session/responses/bolt.rb', line 28

def result_from_data(columns, entities_data)
  rows = entities_data.map do |entity_data|
    wrap_entity(entity_data)
  end

  Result.new(columns, rows)
end

#wrap_entity(entity_data) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/neo4j/core/cypher_session/responses/bolt.rb', line 36

def wrap_entity(entity_data)
  case entity_data
  when Array
    entity_data.map(&method(:wrap_entity))
  when PackStream::Structure
    wrap_structure(entity_data)
  when Hash
    entity_data.each_with_object({}) do |(k, v), result|
      result[k.to_sym] = wrap_entity(v)
    end
  else
    entity_data
  end
end