Sha256: 562007ffa79ac53d47e65a4cd1cc59cb29a9c1e0fa468803c598313622e4fba3

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

module LD::Patch::Algebra

  ##
  # The LD Patch `patch` operator.
  #
  # Transactionally iterates over all operands building bindings along the way
  class Patch < SPARQL::Algebra::Operator
    include SPARQL::Algebra::Update

    NAME = :patch

    ##
    # Executes this upate on the given `transactable` graph or repository.
    #
    # @param  [RDF::Transactable] graph
    #   the graph to update.
    # @param  [Hash{Symbol => Object}] options
    #   any additional options
    # @return [RDF::Transactable]
    #   Returns graph.
    # @raise [Error]
    #   If any error is caught along the way, and rolls back the transaction
    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ld-patch-3.3.0 lib/ld/patch/algebra/patch.rb
ld-patch-3.2.2 lib/ld/patch/algebra/patch.rb
ld-patch-3.2.0 lib/ld/patch/algebra/patch.rb
ld-patch-3.1.3 lib/ld/patch/algebra/patch.rb
ld-patch-3.1.2 lib/ld/patch/algebra/patch.rb