Class: CypherBuilder::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/cypher_builder/infra/runner.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter = Adapter::DEFAULT) ⇒ Runner

Returns a new instance of Runner.

Parameters:

  • adapter (Adapter) (defaults to: Adapter::DEFAULT)


13
14
15
# File 'lib/cypher_builder/infra/runner.rb', line 13

def initialize(adapter = Adapter::DEFAULT)
  @adapter = adapter
end

Class Attribute Details

.cypherCypher

Returns:



5
6
7
# File 'lib/cypher_builder/infra/runner.rb', line 5

def cypher
  @cypher
end

Class Method Details

.exec(adapter = Adapter::DEFAULT, **params) ⇒ Object



7
8
9
# File 'lib/cypher_builder/infra/runner.rb', line 7

def exec(adapter = Adapter::DEFAULT, ** params)
  self.new(adapter).execute(** params)
end

Instance Method Details

#execute(**params) ⇒ Object



17
18
19
20
21
22
# File 'lib/cypher_builder/infra/runner.rb', line 17

def execute(** params)
  payload = Payload.new(params)
  context = Context.new
  cypher = self.class.cypher.as_cypher(payload: payload, context: context)
  @adapter.execute(cypher, payload.necessary)
end