neo4jrb/neo4j-core

View on GitHub
lib/neo4j/core/cypher_session/transactions/embedded.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'neo4j/core/cypher_session/transactions'

module Neo4j
  module Core
    class CypherSession
      module Transactions
        class Embedded < Base
          def initialize(*args)
            super
            @java_tx = adaptor.graph_db.begin_tx
          end

          def commit
            return if !@java_tx

            @java_tx.success
            @java_tx.close
          rescue Java::OrgNeo4jGraphdb::TransactionFailureException => e
            raise CypherError, e.message
          end

          def delete
            return if !@java_tx

            @java_tx.failure
            @java_tx.close
          end
        end
      end
    end
  end
end