RDF.Description.update
You're seeing just the function
update
, go back to RDF.Description module for more information.
Specs
update( t(), RDF.Statement.coercible_predicate(), RDF.Statement.coercible_object() | nil, ([RDF.Statement.Object] -> [RDF.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})