Class: RDF::LMDB::Transaction
- Inherits:
-
Transaction
- Object
- Transaction
- RDF::LMDB::Transaction
- Defined in:
- lib/rdf/lmdb.rb
Overview
???
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(repository, graph_name: nil, mutable: false, **options, &block) ⇒ Transaction
constructor
A new instance of Transaction.
- #rollback ⇒ Object
Constructor Details
#initialize(repository, graph_name: nil, mutable: false, **options, &block) ⇒ Transaction
Returns a new instance of Transaction.
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, **, &block @repository = repository @snapshot = repository.supports?(:snapshots) ? repository.snapshot : repository @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
#execute ⇒ Object
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 |
#rollback ⇒ Object
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 |