lib/ld/patch/algebra/cut.rb
##
# Executes this upate on the given `writable` graph or repository.
#
# @param  [RDF::Queryable] queryable
#   the graph or repository to write
# @param  [Hash{Symbol => Object}] options
#   any additional options
# @return [RDF::Query::Solutions] A single solution including passed bindings with `var` bound to the solution.
# @raise [IOError]
#   If no triples are identified, or the operand is an unbound variable or the operand is an unbound variable.
# @see    http://www.w3.org/TR/sparql11-update/
Executes this upate on the given `writable` graph or repository.
Executes this upate on the given ` writable ` graph or repository .
def execute(queryable, options = {})
      debug(options) {"Cut"}
      bindings = options.fetch(:bindings)
      solution = bindings.first
      var = operand(0)
      raise LD::Patch::Error.new("Operand uses unbound variable #{var.inspect}", code: 400) unless solution.bound?(var)
      var = solution[var]
      cut_count = 0
      queryable.concise_bounded_description(var) do |statement|
        queryable.delete(statement)
        cut_count += 1
      end
      queryable.query({object: var}).each do |statement|
        queryable.delete(statement)
        cut_count += 1
      end
      raise LD::Patch::Error, "Cut removed no triples" unless cut_count > 0
      bindings
    end
def execute ( queryable , options = { } ) debug ( options ) { "Cut" } bindings = options . fetch ( :bindings ) solution = bindings . first var = operand ( 0 ) raise LD :: Patch :: Error . new ( "Operand uses unbound variable #{var.inspect}" , code : 400 ) unless solution . bound? ( var ) var = solution [ var ] cut_count = 0 queryable . concise_bounded_description ( var ) do | statement | queryable . delete ( statement ) cut_count += 1 end queryable . query ( { object : var } ) . each do | statement | queryable . delete ( statement ) cut_count += 1 end raise LD :: Patch :: Error , "Cut removed no triples" unless cut_count > 0 bindings end
Executes this upate on the given `writable` graph or repository.
Executes this upate on the given ` writable ` graph or repository .
# Bind variable # Get triples to delete using consice bounded description # Also delete triples having var in the object position
A single solution including passed bindings with `var` bound to the solution.
A single solution including passed bindings with ` var ` bound to the solution .
RDF::Query::Solutions
[IOError] If no triples are identified, or the operand is an unbound variable or the operand is an unbound variable.
[ IOError ] If no triples are identified or the operand is an unbound variable or the operand is an unbound variable .
queryable
<not_specific>
options
<not_specific>
<not_specific>
options any additional options
options any additional options
see
None