RDF.Graph.update
You're seeing just the function
update
, go back to RDF.Graph module for more information.
Specs
update( t(), RDF.Statement.coercible_subject(), RDF.Description.input() | nil, update_description_fun() ) :: t()
Updates the description of the subject
in graph
with the given function.
If subject
is present in graph
with description
as description,
fun
is invoked with argument description
and its result is used as the new
description of subject
. If subject
is not present in graph
,
initial
is inserted as the description of subject
. The initial value will
not be passed through the update function.
The initial value and the returned objects by the update function will be tried
te coerced to proper RDF descriptions before added. If the initial or returned
description is a RDF.Description
with another subject, the respective
statements are added with subject
as subject.
Examples
iex> RDF.Graph.new({EX.S, EX.p, EX.O})
...> |> RDF.Graph.update(EX.S,
...> fn description -> Description.add(description, {EX.p, EX.O2})
...> end)
RDF.Graph.new([{EX.S, EX.p, EX.O}, {EX.S, EX.p, EX.O2}])
iex> RDF.Graph.new({EX.S, EX.p, EX.O})
...> |> RDF.Graph.update(EX.S,
...> fn _ -> Description.new(EX.S2, init: {EX.p2, EX.O2})
...> end)
RDF.Graph.new([{EX.S, EX.p2, EX.O2}])
iex> RDF.Graph.new()
...> |> RDF.Graph.update(EX.S, Description.new(EX.S, init: {EX.p, EX.O}),
...> fn description -> Description.add(description, {EX.p, EX.O2})
...> end)
RDF.Graph.new([{EX.S, EX.p, EX.O}])