RDF.Dataset.get_and_update
You're seeing just the function
get_and_update
, go back to RDF.Dataset module for more information.
Specs
get_and_update(t(), RDF.Statement.graph_name() | nil, update_graph_fun()) :: {RDF.Graph.t(), input()}
Gets and updates the graph with the given name, in a single pass.
Invokes the passed function on the RDF.Graph
with the given name;
this function should return either {graph_to_return, new_graph}
or :pop
.
If the passed function returns {graph_to_return, new_graph}
, the
return value of get_and_update
is {graph_to_return, new_dataset}
where
new_dataset
is the input Dataset
updated with new_graph
for
the given name.
If the passed function returns :pop
the graph with the given name is
removed and a {removed_graph, new_dataset}
tuple gets returned.
Examples
iex> dataset = RDF.Dataset.new({EX.S, EX.P, EX.O, EX.Graph})
...> RDF.Dataset.get_and_update(dataset, EX.Graph, fn current_graph ->
...> {current_graph, {EX.S, EX.P, EX.NEW}}
...> end)
{RDF.Graph.new({EX.S, EX.P, EX.O}, name: EX.Graph), RDF.Dataset.new({EX.S, EX.P, EX.NEW, EX.Graph})}