Skip to content

Commit

Permalink
improvement: docs/default value for params
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Mar 19, 2021
1 parent 6cfa91c commit e0a3683
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/ash/changeset/changeset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,10 @@ defmodule Ash.Changeset do
end

defp cast_params(changeset, action, params, opts) do
changeset = %{changeset | params: Map.merge(changeset.params || %{}, Enum.into(params, %{}))}
changeset = %{
changeset
| params: Map.merge(changeset.params || %{}, Enum.into(params || %{}, %{}))
}

Enum.reduce(params, changeset, fn {name, value}, changeset ->
cond do
Expand Down
5 changes: 4 additions & 1 deletion lib/ash/options_helpers.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
defmodule Ash.OptionsHelpers do
@moduledoc """
Helpers for working with nimble options
"""

@type schema :: NimbleOptions.schema()

@moduledoc false
def merge_schemas(left, right, section \\ nil) do
new_right =
Enum.map(right, fn {key, value} ->
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ defmodule Ash.MixProject do
Ash.NotLoaded,
Ash.Query.Aggregate,
Ash.Query.Type,
Ash.SatSolver
Ash.SatSolver,
Ash.OptionsHelpers
],
comparable: ~r/Comparable/
]
Expand Down

0 comments on commit e0a3683

Please sign in to comment.