@@ -10,11 +10,7 @@ defmodule DiffoExample.Access.Card do
1010 """
1111
1212 alias Diffo.Provider.BaseInstance
13- alias Diffo.Provider.Instance.Relationship
14- alias Diffo.Provider.Extension.Characteristic
15- alias Diffo.Provider.Assigner
1613 alias Diffo.Provider.Assignment
17- alias Diffo.Provider.Extension.Pool
1814
1915 alias DiffoExample.Access
2016
@@ -74,37 +70,21 @@ defmodule DiffoExample.Access.Card do
7470 argument :characteristic_value_updates , { :array , :term }
7571
7672 change set_attribute ( :resource_state , :operating )
77-
78- change after_action ( fn changeset , result , _context ->
79- with { :ok , result } <- Ash . load ( result , [ :characteristics ] ) ,
80- { :ok , result } <-
81- Characteristic . update_all ( result , changeset , characteristics ( ) ) ,
82- { :ok , result } <- Pool . update_pools ( result , changeset , pools ( ) ) ,
83- { :ok , result } <- Access . get_card_by_id ( result . id ) ,
84- do: { :ok , result }
85- end )
73+ change DiffoExample.Changes.Define
8674 end
8775
8876 update :relate do
8977 description "relates the card with other instances"
9078 argument :relationships , { :array , :struct }
9179
92- change after_action ( fn changeset , result , _context ->
93- with { :ok , result } <- Relationship . relate_instance ( result , changeset ) ,
94- { :ok , result } <- Access . get_card_by_id ( result . id ) ,
95- do: { :ok , result }
96- end )
80+ change DiffoExample.Changes.Relate
9781 end
9882
9983 update :assign_port do
10084 description "relates the card with an instance by assigning a port"
10185 argument :assignment , :struct , constraints: [ instance_of: Assignment ]
10286
103- change after_action ( fn changeset , result , _context ->
104- with { :ok , result } <- Assigner . assign ( result , changeset , :ports ) ,
105- { :ok , result } <- Access . get_card_by_id ( result . id ) ,
106- do: { :ok , result }
107- end )
87+ change { DiffoExample.Changes.Assign , pool: :ports }
10888 end
10989 end
11090end
0 commit comments