Add exclude/1 function for Graph builder blocks

This commit is contained in:
Marcel Otto 2022-04-07 01:08:17 +02:00
parent 178e8315ab
commit f76687530b
3 changed files with 17 additions and 1 deletions

View file

@ -3,7 +3,8 @@ locals_without_parens = [
def_facet_constraint: 2, def_facet_constraint: 2,
def_applicable_facet: 1, def_applicable_facet: 1,
bgp: 1, bgp: 1,
build: 2 build: 2,
exclude: 1
] ]
[ [

View file

@ -12,6 +12,8 @@ defmodule RDF.Graph.Builder do
defdelegate a(s, o1, o2, o3), to: RDF.NS.RDF, as: :type defdelegate a(s, o1, o2, o3), to: RDF.NS.RDF, as: :type
defdelegate a(s, o1, o2, o3, o4), to: RDF.NS.RDF, as: :type defdelegate a(s, o1, o2, o3, o4), to: RDF.NS.RDF, as: :type
defdelegate a(s, o1, o2, o3, o4, o5), to: RDF.NS.RDF, as: :type defdelegate a(s, o1, o2, o3, o4, o5), to: RDF.NS.RDF, as: :type
def exclude(_), do: nil
end end
def build({:__block__, _, block}, opts) do def build({:__block__, _, block}, opts) do

View file

@ -490,6 +490,19 @@ defmodule RDF.Graph.BuilderTest do
end end
end end
test "exclude" do
graph =
RDF.Graph.build do
exclude "this is not a triple"
EX.S |> EX.p(EX.O)
exclude "this is not a triple"
end
assert graph == RDF.graph(EX.S |> EX.p(EX.O))
end
test "opts" do test "opts" do
initial = {EX.S, EX.p(), "init"} initial = {EX.S, EX.p(), "init"}