-
-
Notifications
You must be signed in to change notification settings - Fork 181
/
actor.ex
44 lines (39 loc) · 1.19 KB
/
actor.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
defmodule Ash.Reactor.Dsl.Actor do
@moduledoc """
Specify the actor used to execute an action.
"""
defstruct __identifier__: nil, source: nil, transform: nil
alias Reactor.Template
@type t :: %__MODULE__{
__identifier__: any,
source: Template.Input.t() | Template.Result.t() | Template.Value.t(),
transform: nil | (any -> any) | {module, keyword} | mfa
}
@doc false
def __entity__ do
template_type = Template.type()
%Spark.Dsl.Entity{
name: :actor,
describe: "Specifies the action actor",
args: [:source],
imports: [Reactor.Dsl.Argument],
identifier: {:auto, :unique_integer},
target: __MODULE__,
schema: [
source: [
type: template_type,
required: true,
doc: "What to use as the source of the actor."
],
transform: [
type:
{:or, [{:spark_function_behaviour, Reactor.Step, {Reactor.Step.Transform, 1}}, nil]},
required: false,
default: nil,
doc:
"An optional transformation function which can be used to modify the actor before it is passed to the action."
]
]
}
end
end