Skip to content

Commit d7df5f2

Browse files
committed
rename params
1 parent 5cb0f98 commit d7df5f2

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ Post.random_params!(:create, %{key: "value"})
6666

6767
# With options
6868
Post.random_params!(:create, %{key: "value"}, %{
69-
fill: [:optional_field], # Fill optional fields
70-
unfill: [:required_field] # Leave required fields as nil
69+
populate: [:optional_field], # Fill optional fields
70+
omit: [:required_field] # Leave required fields as nil
7171
})
7272
```
7373

lib/transformer.ex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ defmodule AshRandomParams.Transformer do
1313
def add_random_params(dsl_state) do
1414
action = Builder.build_action_argument(:action, :atom, default: :create)
1515
init_params = Builder.build_action_argument(:init_params, :map, default: %{})
16-
fill = Builder.build_action_argument(:fill, {:array, :atom}, default: [])
17-
unfill = Builder.build_action_argument(:unfill, {:array, :atom}, default: [])
16+
populate = Builder.build_action_argument(:populate, {:array, :atom}, default: [])
17+
omit = Builder.build_action_argument(:omit, {:array, :atom}, default: [])
1818
keep_defaults? = Builder.build_action_argument(:keep_defaults?, :boolean, default: true)
1919

2020
dsl_state
2121
|> Builder.add_action(:action, :random_params,
2222
returns: :map,
23-
arguments: [action, init_params, unfill, fill, keep_defaults?],
23+
arguments: [action, init_params, omit, populate, keep_defaults?],
2424
run: &__MODULE__.do_random_params/2
2525
)
2626
|> Builder.add_interface(:random_params, args: [:action, {:optional, :init_params}])
@@ -44,8 +44,8 @@ defmodule AshRandomParams.Transformer do
4444
arguments: %{
4545
action: action,
4646
init_params: init_params,
47-
unfill: unfill,
48-
fill: fill,
47+
omit: omit,
48+
populate: populate,
4949
keep_defaults?: keep_defaults?
5050
}
5151
} =
@@ -86,7 +86,7 @@ defmodule AshRandomParams.Transformer do
8686
|> Enum.reject(&(&1.name in belongs_to_attrs))
8787
end
8888
end)
89-
|> Enum.reject(&(&1.name in unfill))
89+
|> Enum.reject(&(&1.name in omit))
9090
|> Enum.reject(&(&1.name in init_keys))
9191
|> Map.new(fn %{name: name, default: default} ->
9292
value =
@@ -109,16 +109,16 @@ defmodule AshRandomParams.Transformer do
109109
{random_mod, random_opts} =
110110
random = AshRandomParams.Info.random_params_random!(input.resource)
111111

112-
fields_by_unfill =
112+
fields_by_omit =
113113
candidates
114114
|> Enum.reject(&(&1.name in rel_names))
115115
|> Enum.reject(&(&1.name in belongs_to_attrs))
116-
|> Enum.reject(&(&1.name in unfill))
116+
|> Enum.reject(&(&1.name in omit))
117117
|> Enum.reject(& &1.allow_nil?)
118118

119-
fields_by_fill = candidates |> Enum.filter(&(&1.name in fill))
119+
fields_by_fill = candidates |> Enum.filter(&(&1.name in populate))
120120

121-
(fields_by_unfill ++ fields_by_fill)
121+
(fields_by_omit ++ fields_by_fill)
122122
|> Enum.reject(&(&1.name in init_keys))
123123
|> Map.new(fn %{name: name, default: default} = attr_or_arg ->
124124
value =

test/ash_random_params_test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ defmodule AshRandomParamsTest do
119119
|> Ash.run_action!()
120120
end
121121

122-
test "with fill" do
122+
test "with populate" do
123123
assert %{
124124
author_id: nil,
125125
req_str: "req_str-" <> _,
@@ -132,13 +132,13 @@ defmodule AshRandomParamsTest do
132132
:random_params,
133133
%{
134134
action: :create,
135-
fill: [:opt_str]
135+
populate: [:opt_str]
136136
}
137137
)
138138
|> Ash.run_action!()
139139
end
140140

141-
test "with unfill" do
141+
test "with omit" do
142142
assert %{
143143
author_id: nil,
144144
opt_str: nil,
@@ -151,7 +151,7 @@ defmodule AshRandomParamsTest do
151151
:random_params,
152152
%{
153153
action: :create,
154-
unfill: [:req_str]
154+
omit: [:req_str]
155155
}
156156
)
157157
|> Ash.run_action!()
@@ -210,7 +210,7 @@ defmodule AshRandomParamsTest do
210210
Post.random_params!(
211211
:create,
212212
%{opt_int: 456},
213-
%{fill: [:opt_int]}
213+
%{populate: [:opt_int]}
214214
)
215215
end
216216
end

0 commit comments

Comments
 (0)