Sha256: 70fc286856578efc83b1c8ea2981280a52527d68bbc5748da8668e3ce7d10983

Contents?: true

Size: 1.27 KB

Versions: 40

Compression:

Stored size: 1.27 KB

Contents

require 'neo4j/core/cypher_session/transactions'

module Neo4j
  module Core
    class CypherSession
      module Transactions
        class HTTP < Base
          # Should perhaps have transaction adaptors only define #close
          # commit/delete are, I think, an implementation detail

          def commit
            adaptor.requestor.request(:post, query_path(true)) if started?
          end

          def delete
            adaptor.requestor.request(:delete, query_path) if started?
          end

          def query_path(commit = false)
            if id
              "/db/data/transaction/#{id}"
            else
              '/db/data/transaction'
            end.tap do |path|
              path << '/commit' if commit
            end
          end

          # Takes the transaction URL from Neo4j and parses out the ID
          def apply_id_from_url!(url)
            root.instance_variable_set('@id', url.match(%r{/(\d+)/?$})[1].to_i) if url
            # @id = url.match(%r{/(\d+)/?$})[1].to_i if url
          end

          def started?
            !!id
          end

          def id
            root.instance_variable_get('@id')
          end

          private

          def connection
            adaptor.connection
          end
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
neo4j-core-9.0.0 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-9.0.0.alpha.1 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.1.4 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.1.3 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.1.2 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.1.1 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.1.0 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.0.4 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.0.3 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.0.2 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.0.1 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.2.4 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-8.0.0 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.2.3 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.2.2 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.2.1 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.2.0 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.1.2 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.0.9 lib/neo4j/core/cypher_session/transactions/http.rb
neo4j-core-7.1.1 lib/neo4j/core/cypher_session/transactions/http.rb