RDF.Description.update

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

update(description, predicate, initial \\ nil, fun)

View Source

Specs

update(
  t(),
  RDF.Star.Statement.coercible_predicate(),
  RDF.Star.Statement.coercible_object() | nil,
  ([RDF.Star.Statement.Object] -> [RDF.Star.Statement.Object])
) :: t()

Updates the objects of the predicate in description with the given function.

If predicate is present in description with objects as value, fun is invoked with argument objects and its result is used as the new list of objects of predicate. If predicate is not present in description, initial is inserted as the objects of predicate. The initial value will not be passed through the update function.

The initial value and the returned objects by the update function will automatically coerced to proper RDF object values before added.

Examples

iex> RDF.Description.new(EX.S, init: {EX.p, EX.O})
...> |> RDF.Description.update(EX.p, fn objects -> [EX.O2 | objects] end)
RDF.Description.new(EX.S, init: [{EX.p, EX.O}, {EX.p, EX.O2}])
iex> RDF.Description.new(EX.S)
...> |> RDF.Description.update(EX.p, EX.O, fn _ -> EX.O2 end)
RDF.Description.new(EX.S, init: {EX.p, EX.O})