class Neo4j::Core::CypherSession::Adaptors::Bolt::Message
Represents messages sent to or received from the server
Constants
- CODE_TYPES
- TYPE_CODES
Attributes
args[R]
type[R]
Public Class Methods
interpret_field_value(value)
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/bolt.rb 269 def self.interpret_field_value(value) 270 if value.is_a?(Array) && (1..3).cover?(value[0]) 271 case value[0] 272 when 1 273 {type: :node, identity: value[1], 274 labels: value[2], properties: value[3]} 275 end 276 else 277 value 278 end 279 end
new(type_or_code, *args)
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/bolt.rb 229 def initialize(type_or_code, *args) 230 @type_code = Message.type_code_for(type_or_code) 231 fail "Invalid message type: #{@type_code.inspect}" if !@type_code 232 @type = CODE_TYPES[@type_code] 233 234 @args = args 235 end
type_code_for(type_or_code)
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/bolt.rb 265 def self.type_code_for(type_or_code) 266 type_or_code.is_a?(Integer) ? type_or_code : TYPE_CODES[type_or_code] 267 end
Public Instance Methods
packed_stream()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/bolt.rb 245 def packed_stream 246 PackStream::Packer.new(struct).packed_stream 247 end
struct()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/bolt.rb 237 def struct 238 PackStream::Structure.new(@type_code, @args) 239 end
to_s()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/bolt.rb 241 def to_s 242 "#{ANSI::GREEN}#{@type.to_s.upcase}#{ANSI::CLEAR} #{@args.inspect if !@args.empty?}" 243 end
value()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/bolt.rb 249 def value 250 return if @type != :record 251 @args.map do |arg| 252 # Assuming result is Record 253 field_names = arg[1] 254 255 field_values = arg[2].map do |field_value| 256 Message.interpret_field_value(field_value) 257 end 258 259 Hash[field_names.zip(field_values)] 260 end 261 end