Class: Neo4j::Core::CypherSession::Transactions::HTTP

Inherits:
Base show all
Defined in:
lib/neo4j/core/cypher_session/transactions/http.rb

Instance Attribute Summary

Attributes inherited from Transaction::Base

#root, #session

Instance Method Summary collapse

Methods inherited from Base

#after_commit, #after_commit_registry, #post_close!, #queries, #query

Methods inherited from Transaction::Base

#autoclosed!, #close, #closed?, #expired?, #failed?, #initialize, #inspect, #mark_expired, #mark_failed, #root?

Constructor Details

This class inherits a constructor from Neo4j::Transaction::Base

Instance Method Details

#apply_id_from_url!(url) ⇒ Object

Takes the transaction URL from Neo4j and parses out the ID


30
31
32
33
# File 'lib/neo4j/core/cypher_session/transactions/http.rb', line 30

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

#commitObject

Should perhaps have transaction adaptors only define #close commit/delete are, I think, an implementation detail


11
12
13
# File 'lib/neo4j/core/cypher_session/transactions/http.rb', line 11

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

#deleteObject


15
16
17
# File 'lib/neo4j/core/cypher_session/transactions/http.rb', line 15

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

#idObject


39
40
41
# File 'lib/neo4j/core/cypher_session/transactions/http.rb', line 39

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

#query_path(commit = false) ⇒ Object


19
20
21
22
23
24
25
26
27
# File 'lib/neo4j/core/cypher_session/transactions/http.rb', line 19

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

#started?Boolean


35
36
37
# File 'lib/neo4j/core/cypher_session/transactions/http.rb', line 35

def started?
  !!id
end