RDF.Graph.update

You're seeing just the function update, go back to RDF.Graph module for more information.
Link to this function

update(graph, subject, initial \\ nil, fun)

View Source

Specs

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. If no initial value is given, the graph remains unchanged. If nil is returned by fun, the respective description will be removed from graph.

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}])