mirror of
https://github.com/ash-project/reactor.git
synced 2024-09-19 12:53:19 +12:00
improvement: Add template guards.
This commit is contained in:
parent
181017a884
commit
dfc56a871c
1 changed files with 18 additions and 0 deletions
|
@ -10,4 +10,22 @@ defmodule Reactor.Template do
|
|||
@doc "The type for use in option schemas"
|
||||
@spec type :: Spark.Options.type()
|
||||
def type, do: {:or, [{:struct, Input}, {:struct, Result}, {:struct, Value}]}
|
||||
|
||||
@doc "A guard for input templates"
|
||||
@spec is_input_template(any) :: Macro.output()
|
||||
defguard is_input_template(template) when is_struct(template, Input)
|
||||
|
||||
@doc "A guard for result templates"
|
||||
@spec is_result_template(any) :: Macro.output()
|
||||
defguard is_result_template(template) when is_struct(template, Result)
|
||||
|
||||
@doc "A guard for value templates"
|
||||
@spec is_value_template(any) :: Macro.output()
|
||||
defguard is_value_template(template) when is_struct(template, Value)
|
||||
|
||||
@doc "A guard to detect all template types"
|
||||
@spec is_template(any) :: Macro.output()
|
||||
defguard is_template(template)
|
||||
when is_input_template(template) or is_result_template(template) or
|
||||
is_value_template(template)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue