View Source Ash.Resource.Igniter (ash v3.4.43)

Codemods for working with Ash.Resource modules

Important Details

This interrogates the source code of a resource, not its ultimate compiled state. What this means, is that things like defines_attribute will not return true if the attribute is added by an extension. Only if it appears literally in the source code of the resource or one of its Spark.Dsl.Fragments.

Summary

Functions

Adds the given code block to the resource's actions block

Adds the given code block to the resource's attributes block

Adds the given code block to the block of the resource specified

Adds a bypass to the top of the resource's policies block

Adds the given code block to the resource's identities block

Adds an action if it doesn't already exist

Adds the given code block to the resource's attributes block if there is no existing attribute with the given name

Adds the given code block to the resource's identities block if there is no existing identity with the given name

Adds the given code block to the resource's relationships block

Adds a policy to the bottom of the resource's policies block

Adds the given code block to the resource's relationships block

Adds the given code block to the resource's resource block

Returns true if the given resource defines an action with the provided name

Returns true if the given resource defines an attribute with the provided name

Returns true if the given resource defines an identity with the provided name

Returns true if the given resource defines a relationship with the provided name

Gets the domain from the given resource module

Ensures that created_at and updated_at timestamps exist on the resource

List all resource modules found in the project

Functions

Link to this function

add_action(igniter, resource, action)

View Source

Adds the given code block to the resource's actions block

Link to this function

add_attribute(igniter, resource, attribute)

View Source

Adds the given code block to the resource's attributes block

Link to this function

add_block(igniter, resource, block, chunk)

View Source

Adds the given code block to the block of the resource specified

Link to this function

add_bypass(igniter, resource, condition, body)

View Source

Adds a bypass to the top of the resource's policies block

Link to this function

add_identity(igniter, resource, identity)

View Source

Adds the given code block to the resource's identities block

Link to this function

add_new_action(igniter, resource, name, action)

View Source

Adds an action if it doesn't already exist

Link to this function

add_new_attribute(igniter, resource, name, attribute)

View Source

Adds the given code block to the resource's attributes block if there is no existing attribute with the given name

Link to this function

add_new_identity(igniter, resource, name, identity)

View Source

Adds the given code block to the resource's identities block if there is no existing identity with the given name

Link to this function

add_new_relationship(igniter, resource, name, relationship)

View Source

Adds the given code block to the resource's relationships block

Link to this function

add_policy(igniter, resource, condition, body)

View Source

Adds a policy to the bottom of the resource's policies block

Link to this function

add_relationship(igniter, resource, relationship)

View Source

Adds the given code block to the resource's relationships block

Link to this function

add_resource_configuration(igniter, resource, resource_configuration)

View Source

Adds the given code block to the resource's resource block

Link to this function

defines_action(igniter, resource, name)

View Source
@spec defines_action(Igniter.t(), Ash.Resource.t(), atom()) ::
  {Igniter.t(), true | false}

Returns true if the given resource defines an action with the provided name

Link to this function

defines_attribute(igniter, resource, name)

View Source
@spec defines_attribute(Igniter.t(), Ash.Resource.t(), atom()) ::
  {Igniter.t(), true | false}

Returns true if the given resource defines an attribute with the provided name

Link to this function

defines_identity(igniter, resource, name)

View Source
@spec defines_identity(Igniter.t(), Ash.Resource.t(), atom()) ::
  {Igniter.t(), true | false}

Returns true if the given resource defines an identity with the provided name

Link to this function

defines_relationship(igniter, resource, name)

View Source
@spec defines_relationship(Igniter.t(), Ash.Resource.t(), atom()) ::
  {Igniter.t(), true | false}

Returns true if the given resource defines a relationship with the provided name

Link to this function

domain(igniter, resource)

View Source
@spec domain(Igniter.t(), Ash.Resource.t()) ::
  {:ok, Igniter.t(), Ash.Domain.t()} | {:error, Igniter.t()}

Gets the domain from the given resource module

Link to this function

ensure_primary_action(igniter, resource, type)

View Source
@spec ensure_primary_action(
  Igniter.t(),
  Ash.Resource.t(),
  :create | :read | :update | :destroy
) ::
  Igniter.t()
Link to this function

ensure_timestamps(igniter, resource)

View Source

Ensures that created_at and updated_at timestamps exist on the resource

Link to this function

has_action_with_primary(igniter, resource, type)

View Source
@spec has_action_with_primary(Igniter.t(), Ash.Resource.t(), atom()) ::
  {Igniter.t(), true | false}

List all resource modules found in the project