Module: RDF::Repository::Implementation
- Defined in:
- lib/rdf/repository.rb
Overview
A default Repository implementation supporting atomic writes and serializable transactions.
Constant Summary collapse
- DEFAULT_GRAPH =
false
- SerializedTransaction =
Deprecated.
moved to Transaction::SerializedTransaction
RDF::Transaction::SerializedTransaction
Instance Method Summary collapse
- #apply_changeset(changeset) ⇒ Object
- #graph?(*args) ⇒ Object (also: #has_graph?)
- #isolation_level ⇒ Object
-
#snapshot ⇒ Dataset
A readable & queryable snapshot of the repository for isolated reads.
- #statement?(*args) ⇒ Object (also: #has_statement?)
Instance Method Details
#apply_changeset(changeset) ⇒ Object
374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/rdf/repository.rb', line 374 def apply_changeset(changeset) data = @data changeset.deletes.each do |del| if del.constant? data = delete_from(data, del) else # we need this condition to handle wildcard statements query_pattern(del) { |stmt| data = delete_from(data, stmt) } end end changeset.inserts.each { |ins| data = insert_to(data, ins) } @data = data end |
#graph? ⇒ Boolean #graph?(name) ⇒ Boolean Also known as: has_graph?
307 308 309 310 311 312 313 |
# File 'lib/rdf/repository.rb', line 307 def graph?(*args) case args.length when 0 then false when 1 then @data.key?(args.first) else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)") end end |
#isolation_level ⇒ Object
390 391 392 |
# File 'lib/rdf/repository.rb', line 390 def isolation_level :snapshot end |
#snapshot ⇒ Dataset
A readable & queryable snapshot of the repository for isolated reads.
401 402 403 |
# File 'lib/rdf/repository.rb', line 401 def snapshot self.class.new(data: @data).freeze end |
#statement? ⇒ Boolean #statement?(statement) ⇒ Object Also known as: has_statement?
344 345 346 347 348 349 350 |
# File 'lib/rdf/repository.rb', line 344 def statement?(*args) case args.length when 0 then false when 1 then args.first && statement_in?(@data, args.first) else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)") end end |