class Delfos::Neo4j::QueryExecution::Transactional

Constants

VALID_RESPONSE_MATCHER

Public Class Methods

check_for_error(uri, response) click to toggle source
# File lib/delfos/neo4j/query_execution/transactional.rb, line 25
def self.check_for_error(uri, response)
  return if response.code[VALID_RESPONSE_MATCHER]

  if response.code == "404"
    raise ExpiredTransaction.new(uri, response)
  end

  raise InvalidCommit.new(uri, response)
end
flush!(commit_url) click to toggle source
# File lib/delfos/neo4j/query_execution/transactional.rb, line 15
def self.flush!(commit_url)
  response = Http.new(commit_url).post({ statements: [] }.to_json)

  check_for_error(commit_url, response)

  response.code == "200"
end

Public Instance Methods

perform() click to toggle source
# File lib/delfos/neo4j/query_execution/transactional.rb, line 35
def perform
  self.class.check_for_error(uri, response)

  raise InvalidQuery.new(json["errors"], query, params) if errors?

  transaction_url = URI.parse  header("location") if header("location")
  commit_url      = URI.parse  json["commit"]     if json["commit"]
  expires         = Time.parse json["transaction"]["expires"] if json["transaction"]

  [transaction_url, commit_url, expires]
end

Private Instance Methods

header(name) click to toggle source
# File lib/delfos/neo4j/query_execution/transactional.rb, line 49
def header(name)
  response.each_header.to_a.find { |n, _| n == name }&.last
end
uri() click to toggle source
# File lib/delfos/neo4j/query_execution/transactional.rb, line 53
def uri
  @uri ||= Delfos.neo4j.uri_for("/db/data/transaction")
end