Class: SPARQL::Algebra::Operator::Create
- Includes:
- Update
- Defined in:
- lib/sparql/algebra/operator/create.rb
Overview
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
[34] Create ::= 'CREATE' 'SILENT'? GraphRef
Constant Summary collapse
- NAME =
[:create]
Instance Method Summary collapse
-
#execute(queryable, **options) ⇒ RDF::Queryable
Executes this upate on the given
writablegraph or repository. -
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
Methods included from Update
#empty?, #graph_name=, #unshift, #variables
Instance Method Details
#execute(queryable, **options) ⇒ RDF::Queryable
Executes this upate on the given writable graph or repository.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sparql/algebra/operator/create.rb', line 39 def execute(queryable, **) debug() {"Create"} silent = operands.first == :silent operands.shift if silent iri = operands.first raise ArgumentError, "clear expected a single IRI" if operands.length != 1 || !iri.is_a?(RDF::URI) if queryable.has_graph?(iri) raise IOError, "create operation graph #{iri.to_ntriples} exists" unless silent end queryable end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
57 58 59 60 61 62 63 |
# File 'lib/sparql/algebra/operator/create.rb', line 57 def to_sparql(**) silent = operands.first == :silent str = "CREATE " str << "SILENT " if operands.first == :silent str << "GRAPH " if operands.last.is_a?(RDF::URI) str << operands.last.to_sparql(**) end |