improvement: Add attribute_type to configure archived_at timestamp (#56)

This commit is contained in:
Jechol Lee 2024-08-31 07:14:09 +09:00 committed by GitHub
parent a354c910c7
commit 51a53143ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -8,6 +8,11 @@ defmodule AshArchival.Resource do
default: :archived_at,
doc: "The attribute in which to store the archival flag (the current datetime)."
],
attribute_type: [
type: :atom,
default: :utc_datetime_usec,
doc: "The attribute type."
],
base_filter?: [
type: :atom,
default: false,

View file

@ -33,8 +33,9 @@ defmodule AshArchival.Resource.Transformers.SetupArchival do
defp add_archived_at(dsl_state) do
attribute = AshArchival.Resource.Info.archive_attribute!(dsl_state)
attribute_type = AshArchival.Resource.Info.archive_attribute_type!(dsl_state)
Ash.Resource.Builder.add_new_attribute(dsl_state, attribute, :utc_datetime_usec,
Ash.Resource.Builder.add_new_attribute(dsl_state, attribute, attribute_type,
public?: false,
allow_nil?: true
)