Skip to content

Commit

Permalink
chore: Satisfy Credo consistency check
Browse files Browse the repository at this point in the history
  • Loading branch information
doomspork committed Jan 18, 2024
1 parent c6c76f0 commit 5aa4f01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/ex_machina/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ defmodule ExMachina.Ecto do
|> convert_atom_keys_to_strings
end

defp recursively_strip(record = %{__struct__: _}) do
defp recursively_strip(%{__struct__: _} = record) do
record
|> set_persisted_belongs_to_ids
|> handle_assocs
Expand All @@ -222,7 +222,7 @@ defmodule ExMachina.Ecto do

defp recursively_strip(record), do: record

defp handle_assocs(record = %{__struct__: struct}) do
defp handle_assocs(%{__struct__: struct} = record) do
Enum.reduce(struct.__schema__(:associations), record, fn association_name, record ->
case struct.__schema__(:association, association_name) do
%{__struct__: Ecto.Association.BelongsTo} ->
Expand Down Expand Up @@ -254,7 +254,7 @@ defmodule ExMachina.Ecto do
end
end

defp handle_embeds(record = %{__struct__: struct}) do
defp handle_embeds(%{__struct__: struct} = record) do
Enum.reduce(struct.__schema__(:embeds), record, fn embed_name, record ->
record
|> Map.get(embed_name)
Expand All @@ -277,7 +277,7 @@ defmodule ExMachina.Ecto do
end
end

defp set_persisted_belongs_to_ids(record = %{__struct__: struct}) do
defp set_persisted_belongs_to_ids(%{__struct__: struct} = record) do
Enum.reduce(struct.__schema__(:associations), record, fn association_name, record ->
association = struct.__schema__(:association, association_name)

Expand All @@ -302,7 +302,7 @@ defmodule ExMachina.Ecto do
Map.put(record, association.owner_key, primary_key)
end

defp insert_belongs_to_assocs(record = %{__struct__: struct}, module) do
defp insert_belongs_to_assocs(%{__struct__: struct} = record, module) do
Enum.reduce(struct.__schema__(:associations), record, fn association_name, record ->
case struct.__schema__(:association, association_name) do
association = %{__struct__: Ecto.Association.BelongsTo} ->
Expand All @@ -326,7 +326,7 @@ defmodule ExMachina.Ecto do
end

@doc false
def drop_ecto_fields(record = %{__struct__: struct}) do
def drop_ecto_fields(%{__struct__: struct} = record) do
record
|> Map.from_struct()
|> Map.delete(:__meta__)
Expand Down
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ defmodule ExMachina.Mixfile do
{:ecto_sql, "~> 3.0", optional: true},

# Dev and Test dependencies
{:credo, "~> 1.6", only: :test, runtime: false},
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
{:doctor, "~> 0.21.0", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.17.1", only: :test},
{:ex_doc, "~> 0.28", only: [:dev, :test], runtime: false},
{:jason, "~> 1.0", only: :test},
{:postgrex, "~> 0.17", only: :test}
]
end
Expand Down
3 changes: 3 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
%{
"benchee": {:hex, :benchee, "1.3.0", "f64e3b64ad3563fa9838146ddefb2d2f94cf5b473bdfd63f5ca4d0657bf96694", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "34f4294068c11b2bd2ebf2c59aac9c7da26ffa0068afdf3419f1b176e16c5f81"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"credo": {:hex, :credo, "1.7.3", "05bb11eaf2f2b8db370ecaa6a6bda2ec49b2acd5e0418bc106b73b07128c0436", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "35ea675a094c934c22fb1dca3696f3c31f2728ae6ef5a53b5d648c11180a4535"},
"db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"doctor": {:hex, :doctor, "0.21.0", "20ef89355c67778e206225fe74913e96141c4d001cb04efdeba1a2a9704f1ab5", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "a227831daa79784eb24cdeedfa403c46a4cb7d0eab0e31232ec654314447e4e0"},
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
Expand All @@ -18,5 +20,6 @@
"makeup_erlang": {:hex, :makeup_erlang, "0.1.3", "d684f4bac8690e70b06eb52dad65d26de2eefa44cd19d64a8095e1417df7c8fd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "b78dc853d2e670ff6390b605d807263bf606da3c82be37f9d7f68635bd886fc9"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"postgrex": {:hex, :postgrex, "0.17.4", "5777781f80f53b7c431a001c8dad83ee167bcebcf3a793e3906efff680ab62b3", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "6458f7d5b70652bc81c3ea759f91736c16a31be000f306d3c64bcdfe9a18b3cc"},
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
}

0 comments on commit 5aa4f01

Please sign in to comment.