fix: support all calculate opts in code interface methods (#1026)

This commit is contained in:
Dmitry Maganov 2024-04-16 00:34:33 +03:00 committed by GitHub
parent 11de5dd64f
commit 8bcbfc5b17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 22 deletions

View file

@ -322,7 +322,7 @@ defmodule Ash.CodeInterface do
### Options
#{Spark.Options.docs(Ash.Resource.Interface.interface_options(:calculate))}
#{Spark.Options.docs(opt_schema)}
"""
|> Ash.CodeInterface.trim_double_newlines()
@doc spark_opts: [
@ -351,13 +351,8 @@ defmodule Ash.CodeInterface do
end
)
Ash.calculate!(unquote(resource), unquote(interface.calculation),
domain: unquote(domain),
refs: refs,
args: arguments,
actor: opts[:actor],
record: record
)
opts = [domain: unquote(domain), refs: refs, args: arguments, record: record] ++ opts
Ash.calculate!(unquote(resource), unquote(interface.calculation), opts)
end
@doc """
@ -367,7 +362,7 @@ defmodule Ash.CodeInterface do
### Options
#{Spark.Options.docs(Ash.Resource.Interface.interface_options(:calculate))}
#{Spark.Options.docs(opt_schema)}
"""
|> Ash.CodeInterface.trim_double_newlines()
@doc spark_opts: [
@ -396,13 +391,8 @@ defmodule Ash.CodeInterface do
end
)
Ash.calculate(unquote(resource), unquote(interface.calculation),
domain: unquote(domain),
refs: refs,
args: arguments,
actor: opts[:actor],
record: record
)
opts = [domain: unquote(domain), refs: refs, args: arguments, record: record] ++ opts
Ash.calculate(unquote(resource), unquote(interface.calculation), opts)
end
end

View file

@ -39,12 +39,8 @@ defmodule Ash.Resource.Interface do
end
def interface_options(:calculate) do
[
actor: [
type: :any,
doc: "The actor to use for actor references"
]
]
Ash.calculate_opts()
|> Keyword.drop([:domain, :refs, :args, :record])
end
def interface_options(:create) do