Class: Boltless::StatementCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/boltless/statement_collector.rb

Overview

A shallow interface object to collect multiple Cypher statements. We have an explicit different interface (#add instead ot #run) from a regular transaction to clarify that we just collect statements without running them directly. As a result no subsequent statement can access the results of a previous statement within this collection.

Effectively, we wrap just multiple statements for a single HTTP API/Cypher transaction API request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBoltless::StatementCollector

Setup a new statement collector instance.



26
27
28
# File 'lib/boltless/statement_collector.rb', line 26

def initialize
  @statements = []
end

Instance Attribute Details

#statementsObject (readonly)

We allow to read our collected details



16
17
18
# File 'lib/boltless/statement_collector.rb', line 16

def statements
  @statements
end

Instance Method Details

#add(cypher, **args) ⇒ StatementCollector

Add a new statement to the collector.

Parameters:

  • cypher (String)

    the Cypher statement to run

  • args (Hash{Symbol => Mixed})

    the additional Cypher parameters

Returns:



35
36
37
38
# File 'lib/boltless/statement_collector.rb', line 35

def add(cypher, **args)
  @statements << Request.statement_payload(cypher, **args)
  self
end