Sha256: 5eb03f5312d4290b7d33fcd19872de552d913aa4607913764ad593c9d6320c33

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

module SPARQL; module Algebra
  class Operator

    ##
    # The SPARQL UPDATE `create` operator.
    #
    # This operation creates a graph in the Graph Store
    #
    # This is a no-op for RDF.rb implementations, unless the graph exists
    #
    # @example
    #   (create silent <graph>)
    #
    # @see http://www.w3.org/TR/sparql11-update/#create
    class Create < Operator
      include SPARQL::Algebra::Update

      NAME = [:create]

      ##
      # 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 keyword options
      # @option options [Boolean] debug
      #   Query execution debugging
      # @return [RDF::Queryable]
      #   Returns queryable.
      # @raise [IOError]
      #   If `from` does not exist, unless the `silent` operator is present
      # @see    http://www.w3.org/TR/sparql11-update/
      def execute(queryable, options = {})
        debug(options) {"Create"}
        silent = operands.first == :silent
        operands.shift if silent

        iri = operands.first
        #require 'byebug'; byebug
        raise ArgumentError, "clear expected a single IRI" if operands.length != 1 || !iri.is_a?(RDF::URI)
        if queryable.has_context?(iri)
          raise IOError, "create operation graph #{iri.to_ntriples} exists" unless silent
        end
        queryable
      end
    end # Create
  end # Operator
end; end # SPARQL::Algebra

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sparql-1.1.8 lib/sparql/algebra/operator/create.rb
sparql-1.1.7 lib/sparql/algebra/operator/create.rb
sparql-1.1.6 lib/sparql/algebra/operator/create.rb