ash v0.1.9 Ash.Type behaviour View Source

This behaviour is a superset of the Ecto.Type behavior, that also contains api level information, like what kinds of filters are allowed. Eventually, this may be used for composite types or serialization.

Much better to use Ash.Type than to say @behaviour Ash.Type and define everything yourself.

Link to this section Summary

Functions

Returns true if the value is a builtin type or adopts the Ash.Type behaviour

A list of the built in type names

Casts input (e.g. unknown) data to an instance of the type, or errors

Casts a value from the data store to an instance of the type, or errors

Casts a value from the Elixir type to a value that the data store can persist

Returns the ecto compatible type for an Ash.Type.

Determines if two values of a given type are equal.

Determines whether or not this value can be sorted.

Returns the underlying storage type (the underlying type of the ecto type of the ash type)

Link to this section Types

Link to this section Functions

Link to this function

ash_type?(atom)

View Source
ash_type?(term()) :: boolean()

Returns true if the value is a builtin type or adopts the Ash.Type behaviour

Link to this function

builtins()

View Source
builtins() :: [atom()]

A list of the built in type names

Link to this function

cast_input(type, term)

View Source
cast_input(t(), term()) :: {:ok, term()} | {:error, keyword()} | :error

Casts input (e.g. unknown) data to an instance of the type, or errors

Maps to Ecto.Type.cast/2

Link to this function

cast_stored(type, term)

View Source
cast_stored(t(), term()) :: {:ok, term()} | {:error, keyword()} | :error

Casts a value from the data store to an instance of the type, or errors

Maps to Ecto.Type.load/2

Link to this function

dump_to_native(type, term)

View Source
dump_to_native(t(), term()) :: {:ok, term()} | {:error, keyword()} | :error

Casts a value from the Elixir type to a value that the data store can persist

Maps to Ecto.Type.dump/2

Link to this function

ecto_type(type)

View Source
ecto_type(t()) :: Ecto.Type.t()

Returns the ecto compatible type for an Ash.Type.

If you use Ash.Type, this is created for you. For builtin types this may return a corresponding ecto builtin type (atom)

Link to this function

equal?(type, left, right)

View Source
equal?(t(), term(), term()) :: boolean()

Determines if two values of a given type are equal.

Maps to Ecto.Type.equal?/3

Link to this function

get_type(value)

View Source
get_type(atom() | module()) :: atom() | module()
Link to this function

sortable?(type, data_layer)

View Source
sortable?(t(), Ash.data_layer()) :: boolean()

Determines whether or not this value can be sorted.

Link to this function

storage_type(type)

View Source
storage_type(t()) :: Ecto.Type.t()

Returns the underlying storage type (the underlying type of the ecto type of the ash type)

Link to this function

supports_filter?(resource, type, filter_type, data_layer)

View Source
supports_filter?(
  Ash.resource(),
  t(),
  Ash.DataLayer.filter_type(),
  Ash.data_layer()
) :: boolean()

Link to this section Callbacks

Link to this callback

cast_input(term)

View Source
cast_input(term()) :: {:ok, term()} | {:error, keyword()} | :error
Link to this callback

cast_stored(term)

View Source
cast_stored(term()) :: {:ok, term()} | :error
Link to this callback

dump_to_native(term)

View Source
dump_to_native(term()) :: {:ok, term()} | :error
Link to this callback

equal?(term, term)

View Source
equal?(term(), term()) :: boolean()
Link to this callback

storage_type()

View Source
storage_type() :: Ecto.Type.t()
Link to this callback

supported_filter_types(arg1)

View Source
supported_filter_types(Ash.data_layer()) :: [atom()]