Class: RDF::Transaction
- Inherits:
-
Object
- Object
- RDF::Transaction
- Includes:
- Mutable
- Defined in:
- lib/rdf/transaction.rb
Overview
An RDF transaction.
Transactions consist of a sequence of RDF statements to delete from and a sequence of RDF statements to insert into a given named graph.
Instance Attribute Summary (collapse)
-
- (RDF::Enumerable) deletes
readonly
RDF statements to delete when executed.
-
- (RDF::Resource) graph
readonly
RDF graph to modify when executed.
-
- (RDF::Enumerable) inserts
readonly
RDF statements to insert when executed.
-
- (Hash{Symbol => Object}) options
readonly
Any additional options for this transaction.
Class Method Summary (collapse)
-
+ execute(repository, options = {}) {|tx| ... }
Executes a transaction against the given RDF repository.
Instance Method Summary (collapse)
-
- delete_statement(statement)
protected
Appends an RDF statement to the sequence to delete when executed.
-
- execute(repository, options = {})
Executes this transaction against the given RDF repository.
-
- (Transaction) initialize(options = {}) {|tx| ... }
constructor
Initializes this transaction.
-
- insert_statement(statement)
protected
Appends an RDF statement to the sequence to insert when executed.
-
- (String) inspect
Returns a developer-friendly representation of this transaction.
-
- inspect!
Outputs a developer-friendly representation of this transaction to
stderr. -
- (Boolean) readable?
Returns
falseto indicate that this transaction is append-only.
Methods included from Mutable
#<<, #clear, #delete, #delete_statements, #immutable?, #insert, #load, #mutable?, #update
Methods included from Util::Aliasing::LateBound
Methods included from Writable
#<<, #insert, #insert_graph, #insert_reader, #insert_statements, #writable?
Constructor Details
- (Transaction) initialize(options = {}) {|tx| ... }
Initializes this transaction.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rdf/transaction.rb', line 65 def initialize( = {}, &block) = .dup @graph = .delete(:graph) || .delete(:context) @inserts = .delete(:insert) || RDF::Graph.new @deletes = .delete(:delete) || RDF::Graph.new @inserts.extend(RDF::Enumerable) unless @inserts.kind_of?(RDF::Enumerable) @deletes.extend(RDF::Enumerable) unless @deletes.kind_of?(RDF::Enumerable) if block_given? case block.arity when 1 then block.call(self) else instance_eval(&block) end end end |
Instance Attribute Details
- (RDF::Enumerable) deletes (readonly)
RDF statements to delete when executed.
42 43 44 |
# File 'lib/rdf/transaction.rb', line 42 def deletes @deletes end |
- (RDF::Resource) graph (readonly)
RDF graph to modify when executed.
36 37 38 |
# File 'lib/rdf/transaction.rb', line 36 def graph @graph end |
- (RDF::Enumerable) inserts (readonly)
RDF statements to insert when executed.
48 49 50 |
# File 'lib/rdf/transaction.rb', line 48 def inserts @inserts end |
- (Hash{Symbol => Object}) options (readonly)
Any additional options for this transaction.
54 55 56 |
# File 'lib/rdf/transaction.rb', line 54 def end |
Class Method Details
+ execute(repository, options = {}) {|tx| ... }
This method returns an undefined value.
Executes a transaction against the given RDF repository.
28 29 30 |
# File 'lib/rdf/transaction.rb', line 28 def self.execute(repository, = {}, &block) self.new(&block).execute(repository, ) end |
Instance Method Details
- delete_statement(statement) (protected)
This method returns an undefined value.
Appends an RDF statement to the sequence to delete when executed.
153 154 155 |
# File 'lib/rdf/transaction.rb', line 153 def delete_statement(statement) deletes << statement end |
- execute(repository, options = {})
This method returns an undefined value.
Executes this transaction against the given RDF repository.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/rdf/transaction.rb', line 100 def execute(repository, = {}) before_execute(repository, ) if respond_to?(:before_execute) deletes.each_statement do |statement| statement = statement.dup statement.context = graph repository.delete(statement) end inserts.each_statement do |statement| statement = statement.dup statement.context = graph repository.insert(statement) end after_execute(repository, ) if respond_to?(:after_execute) self end |
- insert_statement(statement) (protected)
This method returns an undefined value.
Appends an RDF statement to the sequence to insert when executed.
143 144 145 |
# File 'lib/rdf/transaction.rb', line 143 def insert_statement(statement) inserts << statement end |
- (String) inspect
Returns a developer-friendly representation of this transaction.
123 124 125 126 |
# File 'lib/rdf/transaction.rb', line 123 def inspect sprintf("#<%s:%#0x(graph: %s, deletes: %d, inserts: %d)>", self.class.name, __id__, graph ? graph.to_s : 'nil', deletes.count, inserts.count) end |
- inspect!
This method returns an undefined value.
Outputs a developer-friendly representation of this transaction to
stderr.
133 134 135 |
# File 'lib/rdf/transaction.rb', line 133 def inspect! warn(inspect) end |
- (Boolean) readable?
90 91 92 |
# File 'lib/rdf/transaction.rb', line 90 def readable? false end |