Replace all uses of Enum.empty? with the dedicated empty? functions
This commit is contained in:
parent
bf158d90ae
commit
9e62b23a77
6 changed files with 10 additions and 10 deletions
|
@ -319,7 +319,7 @@ defmodule RDF.Dataset do
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
dataset
|
dataset
|
||||||
| graphs:
|
| graphs:
|
||||||
if Enum.empty?(new_graph) do
|
if Graph.empty?(new_graph) do
|
||||||
Map.delete(dataset.graphs, graph_name)
|
Map.delete(dataset.graphs, graph_name)
|
||||||
else
|
else
|
||||||
Map.put(dataset.graphs, graph_name, new_graph)
|
Map.put(dataset.graphs, graph_name, new_graph)
|
||||||
|
@ -475,7 +475,7 @@ defmodule RDF.Dataset do
|
||||||
{{s, p, o}, popped_graph} = Graph.pop(graph)
|
{{s, p, o}, popped_graph} = Graph.pop(graph)
|
||||||
|
|
||||||
popped =
|
popped =
|
||||||
if Enum.empty?(popped_graph),
|
if Graph.empty?(popped_graph),
|
||||||
do: graphs |> Map.delete(graph_name),
|
do: graphs |> Map.delete(graph_name),
|
||||||
else: graphs |> Map.put(graph_name, popped_graph)
|
else: graphs |> Map.put(graph_name, popped_graph)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ defmodule RDF.Diff do
|
||||||
defp coerce_graph(nil), do: Graph.new()
|
defp coerce_graph(nil), do: Graph.new()
|
||||||
|
|
||||||
defp coerce_graph(%Description{} = description),
|
defp coerce_graph(%Description{} = description),
|
||||||
do: if(Enum.empty?(description), do: Graph.new(), else: Graph.new(description))
|
do: if(Description.empty?(description), do: Graph.new(), else: Graph.new(description))
|
||||||
|
|
||||||
defp coerce_graph(data), do: Graph.new(init: data)
|
defp coerce_graph(data), do: Graph.new(init: data)
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,7 @@ defmodule RDF.Graph do
|
||||||
def add(graph, input, opts \\ [])
|
def add(graph, input, opts \\ [])
|
||||||
|
|
||||||
def add(%__MODULE__{descriptions: descriptions} = graph, %Description{} = description, opts) do
|
def add(%__MODULE__{descriptions: descriptions} = graph, %Description{} = description, opts) do
|
||||||
if Enum.empty?(description) do
|
if Description.empty?(description) do
|
||||||
graph
|
graph
|
||||||
else
|
else
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
|
@ -430,7 +430,7 @@ defmodule RDF.Graph do
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
graph
|
graph
|
||||||
| descriptions:
|
| descriptions:
|
||||||
if Enum.empty?(new_description) do
|
if Description.empty?(new_description) do
|
||||||
Map.delete(descriptions, subject)
|
Map.delete(descriptions, subject)
|
||||||
else
|
else
|
||||||
Map.put(descriptions, subject, new_description)
|
Map.put(descriptions, subject, new_description)
|
||||||
|
@ -739,7 +739,7 @@ defmodule RDF.Graph do
|
||||||
{triple, popped_description} = Description.pop(description)
|
{triple, popped_description} = Description.pop(description)
|
||||||
|
|
||||||
popped =
|
popped =
|
||||||
if Enum.empty?(popped_description),
|
if Description.empty?(popped_description),
|
||||||
do: descriptions |> Map.delete(subject),
|
do: descriptions |> Map.delete(subject),
|
||||||
else: descriptions |> Map.put(subject, popped_description)
|
else: descriptions |> Map.put(subject, popped_description)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ defimpl Inspect, for: RDF.Description do
|
||||||
|
|
||||||
header = "#RDF.Description<subject: #{inspect(description.subject)}"
|
header = "#RDF.Description<subject: #{inspect(description.subject)}"
|
||||||
|
|
||||||
if Enum.empty?(description) do
|
if RDF.Description.empty?(description) do
|
||||||
header <> ">"
|
header <> ">"
|
||||||
else
|
else
|
||||||
body =
|
body =
|
||||||
|
|
|
@ -253,7 +253,7 @@ defmodule RDF.Turtle.Encoder do
|
||||||
defp blank_node_property_list(description, state, nesting) do
|
defp blank_node_property_list(description, state, nesting) do
|
||||||
indented = nesting + @indentation
|
indented = nesting + @indentation
|
||||||
|
|
||||||
if Enum.empty?(description) do
|
if Description.empty?(description) do
|
||||||
"[]"
|
"[]"
|
||||||
else
|
else
|
||||||
"[" <>
|
"[" <>
|
||||||
|
@ -348,7 +348,7 @@ defmodule RDF.Turtle.Encoder do
|
||||||
defp list_subject_description(description) do
|
defp list_subject_description(description) do
|
||||||
description = Description.delete_predicates(description, [RDF.first(), RDF.rest()])
|
description = Description.delete_predicates(description, [RDF.first(), RDF.rest()])
|
||||||
|
|
||||||
if Enum.count(description.predications) == 0 do
|
if Description.empty?(description) do
|
||||||
# since the Turtle grammar doesn't allow bare lists, we add a statement
|
# since the Turtle grammar doesn't allow bare lists, we add a statement
|
||||||
description |> RDF.type(RDF.List)
|
description |> RDF.type(RDF.List)
|
||||||
else
|
else
|
||||||
|
|
|
@ -73,7 +73,7 @@ defmodule RDF.Star.Graph do
|
||||||
description_without_quoted_triples =
|
description_without_quoted_triples =
|
||||||
Description.without_quoted_triple_objects(description)
|
Description.without_quoted_triple_objects(description)
|
||||||
|
|
||||||
if Enum.empty?(description_without_quoted_triples) do
|
if Description.empty?(description_without_quoted_triples) do
|
||||||
Map.delete(descriptions, subject)
|
Map.delete(descriptions, subject)
|
||||||
else
|
else
|
||||||
Map.put(descriptions, subject, description_without_quoted_triples)
|
Map.put(descriptions, subject, description_without_quoted_triples)
|
||||||
|
|
Loading…
Reference in a new issue