Provide fallback implementations for Enumerable.slice/1
This commit is contained in:
parent
4b26493c9f
commit
56436f85af
4 changed files with 11 additions and 6 deletions
|
@ -726,8 +726,9 @@ defmodule RDF.Dataset do
|
||||||
|
|
||||||
|
|
||||||
defimpl Enumerable do
|
defimpl Enumerable do
|
||||||
def member?(graph, statement), do: {:ok, RDF.Dataset.include?(graph, statement)}
|
def member?(dataset, statement), do: {:ok, RDF.Dataset.include?(dataset, statement)}
|
||||||
def count(graph), do: {:ok, RDF.Dataset.statement_count(graph)}
|
def count(dataset), do: {:ok, RDF.Dataset.statement_count(dataset)}
|
||||||
|
def slice(_dataset), do: {:error, __MODULE__}
|
||||||
|
|
||||||
def reduce(%RDF.Dataset{graphs: graphs}, {:cont, acc}, _fun)
|
def reduce(%RDF.Dataset{graphs: graphs}, {:cont, acc}, _fun)
|
||||||
when map_size(graphs) == 0, do: {:done, acc}
|
when map_size(graphs) == 0, do: {:done, acc}
|
||||||
|
|
|
@ -570,8 +570,9 @@ defmodule RDF.Description do
|
||||||
|
|
||||||
|
|
||||||
defimpl Enumerable do
|
defimpl Enumerable do
|
||||||
def member?(desc, triple), do: {:ok, RDF.Description.include?(desc, triple)}
|
def member?(desc, triple), do: {:ok, RDF.Description.include?(desc, triple)}
|
||||||
def count(desc), do: {:ok, RDF.Description.count(desc)}
|
def count(desc), do: {:ok, RDF.Description.count(desc)}
|
||||||
|
def slice(_desc), do: {:error, __MODULE__}
|
||||||
|
|
||||||
def reduce(%RDF.Description{predications: predications}, {:cont, acc}, _fun)
|
def reduce(%RDF.Description{predications: predications}, {:cont, acc}, _fun)
|
||||||
when map_size(predications) == 0, do: {:done, acc}
|
when map_size(predications) == 0, do: {:done, acc}
|
||||||
|
|
|
@ -600,8 +600,9 @@ defmodule RDF.Graph do
|
||||||
|
|
||||||
|
|
||||||
defimpl Enumerable do
|
defimpl Enumerable do
|
||||||
def member?(desc, triple), do: {:ok, RDF.Graph.include?(desc, triple)}
|
def member?(graph, triple), do: {:ok, RDF.Graph.include?(graph, triple)}
|
||||||
def count(desc), do: {:ok, RDF.Graph.triple_count(desc)}
|
def count(graph), do: {:ok, RDF.Graph.triple_count(graph)}
|
||||||
|
def slice(_graph), do: {:error, __MODULE__}
|
||||||
|
|
||||||
def reduce(%RDF.Graph{descriptions: descriptions}, {:cont, acc}, _fun)
|
def reduce(%RDF.Graph{descriptions: descriptions}, {:cont, acc}, _fun)
|
||||||
when map_size(descriptions) == 0, do: {:done, acc}
|
when map_size(descriptions) == 0, do: {:done, acc}
|
||||||
|
@ -615,6 +616,7 @@ defmodule RDF.Graph do
|
||||||
def reduce(%RDF.Graph{} = graph, {:suspend, acc}, fun) do
|
def reduce(%RDF.Graph{} = graph, {:suspend, acc}, fun) do
|
||||||
{:suspended, acc, &reduce(graph, &1, fun)}
|
{:suspended, acc, &reduce(graph, &1, fun)}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -240,5 +240,6 @@ defmodule RDF.List do
|
||||||
|
|
||||||
def member?(_, _), do: {:error, __MODULE__}
|
def member?(_, _), do: {:error, __MODULE__}
|
||||||
def count(_), do: {:error, __MODULE__}
|
def count(_), do: {:error, __MODULE__}
|
||||||
|
def slice(_), do: {:error, __MODULE__}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue