mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 21:43:02 +12:00
34 lines
648 B
Elixir
34 lines
648 B
Elixir
|
defmodule Ash.Test.Support.PolicySimple.Foo do
|
||
|
@moduledoc false
|
||
|
use Ash.Resource,
|
||
|
domain: Ash.Test.Support.PolicySimple.Domain,
|
||
|
data_layer: Ash.DataLayer.Ets,
|
||
|
authorizers: [
|
||
|
Ash.Policy.Authorizer
|
||
|
]
|
||
|
|
||
|
policies do
|
||
|
policy action_type(:create) do
|
||
|
authorize_if(changing_attributes(name: [to: "Foo"]))
|
||
|
end
|
||
|
|
||
|
policy action_type(:read) do
|
||
|
authorize_if(always())
|
||
|
end
|
||
|
end
|
||
|
|
||
|
ets do
|
||
|
private?(true)
|
||
|
end
|
||
|
|
||
|
attributes do
|
||
|
uuid_primary_key(:id)
|
||
|
attribute(:name, :string, public?: true)
|
||
|
end
|
||
|
|
||
|
actions do
|
||
|
default_accept :*
|
||
|
defaults [:read, :destroy, create: :*, update: :*]
|
||
|
end
|
||
|
end
|