mirror of
https://github.com/ash-project/ash.git
synced 2024-09-21 05:53:06 +12:00
66 lines
1.1 KiB
Elixir
66 lines
1.1 KiB
Elixir
defmodule Ash.Test.Flow.ChildResource do
|
|
@moduledoc false
|
|
use Ash.Resource,
|
|
authorizers: [Ash.Policy.Authorizer],
|
|
data_layer: Ash.DataLayer.Ets
|
|
|
|
ets do
|
|
private? true
|
|
end
|
|
|
|
actions do
|
|
create :create do
|
|
primary? true
|
|
|
|
argument :parent_resource, Ash.Test.Flow.ParentResource
|
|
|
|
change manage_relationship(:parent_resource, type: :append)
|
|
end
|
|
|
|
update :system_cancel do
|
|
change set_attribute(:status, :canceled)
|
|
|
|
reject :all
|
|
end
|
|
|
|
read :read do
|
|
primary? true
|
|
argument :build, :map
|
|
|
|
prepare build(arg(:build))
|
|
end
|
|
end
|
|
|
|
policies do
|
|
policy action(:read) do
|
|
authorize_if always()
|
|
end
|
|
|
|
policy action(:system_cancel) do
|
|
authorize_if always()
|
|
end
|
|
end
|
|
|
|
attributes do
|
|
uuid_primary_key :id
|
|
|
|
attribute :status, :atom do
|
|
default :active
|
|
allow_nil? false
|
|
end
|
|
|
|
create_timestamp :created_at do
|
|
private? false
|
|
end
|
|
|
|
update_timestamp :updated_at do
|
|
private? false
|
|
end
|
|
end
|
|
|
|
relationships do
|
|
belongs_to :parent_resource, Ash.Test.Flow.ParentResource do
|
|
allow_nil? false
|
|
end
|
|
end
|
|
end
|