Class: RDF::LMDB::Transaction

Inherits:
Transaction
  • Object
show all
Defined in:
lib/rdf/lmdb.rb

Overview

???

Instance Method Summary collapse

Constructor Details

#initialize(repository, graph_name: nil, mutable: false, **options, &block) ⇒ Transaction

Returns a new instance of Transaction.

Raises:

  • (TransactionError)


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/rdf/lmdb.rb', line 65

def initialize repository,
    graph_name: nil, mutable: false, **options, &block
  @repository = repository
  @snapshot =
    repository.supports?(:snapshots) ? repository.snapshot : repository
  @options    = options.dup
  @mutable    = mutable
  @graph_name = graph_name

  raise TransactionError,
    'Tried to open a mutable transaction on an immutable repository' if
    @mutable && !@repository.mutable?

  @changes = RDF::Changeset.new

  #warn caller[0]

  wrap_txn(&block) if block_given?
end

Instance Method Details

#executeObject

Raises:

  • (TransactionError)


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/rdf/lmdb.rb', line 85

def execute
  raise TransactionError,
    'Cannot execute a rolled back transaction. Open a new one instead.' if
    @rolledback

  ret = if @txn
          @changes.apply(@repository)
        else
          wrap_txn { @changes.apply(@repository) }
        end

  @changes = RDF::Changeset.new

  ret
end

#rollbackObject



101
102
103
104
105
106
107
108
# File 'lib/rdf/lmdb.rb', line 101

def rollback
  if @txn
    @txn.abort
    @txn = nil
  end

  super
end