@@ -15,12 +15,11 @@ defmodule AshRandomParams.Transformer do
1515 init_params = Builder . build_action_argument ( :init_params , :map , default: % { } )
1616 fill = Builder . build_action_argument ( :fill , { :array , :atom } , default: [ ] )
1717 unfill = Builder . build_action_argument ( :unfill , { :array , :atom } , default: [ ] )
18- tagged_unions = Builder . build_action_argument ( :tagged_unions , :map , default: % { } )
1918
2019 dsl_state
2120 |> Builder . add_action ( :action , :random_params ,
2221 returns: :map ,
23- arguments: [ action , init_params , unfill , fill , tagged_unions ] ,
22+ arguments: [ action , init_params , unfill , fill ] ,
2423 run: & __MODULE__ . do_random_params / 2
2524 )
2625 |> Builder . add_interface ( :random_params , args: [ :action , { :optional , :init_params } ] )
@@ -45,8 +44,7 @@ defmodule AshRandomParams.Transformer do
4544 action: action ,
4645 init_params: init_params ,
4746 unfill: unfill ,
48- fill: fill ,
49- tagged_unions: tagged_unions
47+ fill: fill
5048 }
5149 } =
5250 input ,
@@ -57,7 +55,6 @@ defmodule AshRandomParams.Transformer do
5755
5856 action = Ash.Resource.Info . action ( resource , action )
5957 init_keys = init_params |> Map . keys ( )
60- union_keys = tagged_unions |> Map . values ( )
6158
6259 belongs_to_attrs =
6360 resource
@@ -97,7 +94,6 @@ defmodule AshRandomParams.Transformer do
9794 candidates
9895 |> Enum . reject ( & ( & 1 . name in rel_names ) )
9996 |> Enum . reject ( & ( & 1 . name in belongs_to_attrs ) )
100- |> Enum . reject ( & ( & 1 . name in union_keys ) )
10197 |> Enum . reject ( & ( & 1 . name in unfill ) )
10298 |> Enum . reject ( & & 1 . allow_nil? )
10399
@@ -124,27 +120,6 @@ defmodule AshRandomParams.Transformer do
124120
125121 result_params = placeholder |> Map . merge ( init_params ) |> Map . merge ( generated_params )
126122
127- union_params =
128- tagged_unions
129- |> Enum . reject ( fn { _tag_field , union_field } -> union_field in init_keys end )
130- |> Map . new ( fn { tag_field , union_field } ->
131- union_attr = resource |> Ash.Resource.Info . attribute ( union_field )
132- subtype_tag = result_params |> Map . fetch! ( tag_field )
133-
134- { random_mod , random_opts } = random = AshRandomParams.Info . random_params_random! ( resource )
135-
136- union_value =
137- random_mod . random ( union_attr , random_opts , % {
138- random: random ,
139- action_context: ctx ,
140- subtype_tag: subtype_tag
141- } )
142-
143- { union_field , union_value }
144- end )
145-
146- result_params = Map . merge ( result_params , union_params )
147-
148123 { :ok , result_params }
149124 end
150125
0 commit comments