RDF.Graph.get_and_update
You're seeing just the function
get_and_update
, go back to RDF.Graph module for more information.
Specs
get_and_update( t(), RDF.Statement.coercible_subject(), get_and_update_description_fun() ) :: {RDF.Description.t(), input()}
Gets and updates the description of the given subject, in a single pass.
Invokes the passed function on the RDF.Description
of the given subject;
this function should return either {description_to_return, new_description}
or :pop
.
If the passed function returns {description_to_return, new_description}
, the
return value of get_and_update
is {description_to_return, new_graph}
where
new_graph
is the input Graph
updated with new_description
for
the given subject.
If the passed function returns :pop
the description for the given subject is
removed and a {removed_description, new_graph}
tuple gets returned.
Examples
iex> RDF.Graph.new({EX.S, EX.P, EX.O})
...> |> RDF.Graph.get_and_update(EX.S, fn current_description ->
...> {current_description, {EX.P, EX.NEW}}
...> end)
{RDF.Description.new(EX.S, init: {EX.P, EX.O}), RDF.Graph.new({EX.S, EX.P, EX.NEW})}