Module: RDF::Repository::Implementation

Defined in:
lib/rdf/repository.rb

Overview

A default Repository implementation supporting atomic writes and serializable transactions.

See Also:

Defined Under Namespace

Classes: SerializedTransaction

Constant Summary collapse

DEFAULT_GRAPH =
false

Instance Method Summary collapse

Instance Method Details

#apply_changeset(changeset) ⇒ Object


367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/rdf/repository.rb', line 367

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?

Overloads:

  • #graph?Boolean

    Returns false to indicate that this is not a graph.

    Returns:

    • (Boolean)
  • #graph?(name) ⇒ Boolean

    Returns true if self contains the given RDF graph_name.

    Parameters:

    • graph_name (RDF::Resource, false)

      Use value false to query for the default graph_name

    Returns:

    • (Boolean)

300
301
302
303
304
305
306
# File 'lib/rdf/repository.rb', line 300

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_levelObject


383
384
385
# File 'lib/rdf/repository.rb', line 383

def isolation_level
  :serializable
end

#snapshotDataset

A readable & queryable snapshot of the repository for isolated reads.

Returns:

  • (Dataset)

    an immutable Dataset containing a current snapshot of the Repository contents.

See Also:


394
395
396
# File 'lib/rdf/repository.rb', line 394

def snapshot
  self.class.new(data: @data).freeze
end

#statement?Boolean #statement?(statement) ⇒ Object Also known as: has_statement?

Overloads:

  • #statement?Boolean

    Returns false indicating this is not an RDF::Statemenet.

    Returns:

    • (Boolean)

    See Also:

  • #statement?(statement) ⇒ Object

337
338
339
340
341
342
343
# File 'lib/rdf/repository.rb', line 337

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