Class: LD::Patch::Algebra::Patch

Inherits:
SPARQL::Algebra::Operator
  • Object
show all
Includes:
SPARQL::Algebra::Update
Defined in:
lib/ld/patch/algebra/patch.rb

Overview

The LD Patch patch operator.

Transactionally iterates over all operands building bindings along the way

Constant Summary collapse

NAME =
:patch

Instance Method Summary collapse

Instance Method Details

#execute(graph, options = {}) ⇒ RDF::Transactable

Executes this upate on the given transactable graph or repository.

Parameters:

  • graph (RDF::Transactable)

    the graph to update.

  • options (Hash{Symbol => Object}) (defaults to: {})

    any additional options

Returns:

  • (RDF::Transactable)

    Returns graph.

Raises:

  • (Error)

    If any error is caught along the way, and rolls back the transaction



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ld/patch/algebra/patch.rb', line 23

def execute(graph, options = {})
  debug(options) {"Delete"}

  if graph.respond_to?(:transaction)
    graph.transaction(mutable: true) do |tx|
      operands.inject(RDF::Query::Solutions.new([RDF::Query::Solution.new])) do |bindings, op|
        # Invoke operand using bindings from prvious operation
        op.execute(tx, options.merge(bindings: bindings))
      end
    end
  else
    operands.inject(RDF::Query::Solutions.new([RDF::Query::Solution.new])) do |bindings, op|
      # Invoke operand using bindings from prvious operation
      op.execute(graph, options.merge(bindings: bindings))
    end
  end
end