AshScim.Igniter (ash_scim v0.1.0)

Copy Markdown View Source

Igniter helpers used by mix ash_scim.install and friends. None of these touch runtime introspection — they all read and write the project's source files via Igniter so the installer can run before the user's code is compiled.

Summary

Functions

Adds a scim do ... end block with the given body to the resource if one isn't already declared. Idempotent — re-running won't duplicate the contents.

Adds the AshScim.Checks.AshScimInteraction bypass policy to the resource. Idempotent — re-running won't duplicate the bypass.

Returns {igniter, true} if the resource already declares a scim DSL block, {igniter, false} otherwise. Used to make the installer idempotent.

Functions

add_scim_section(igniter, resource, body)

@spec add_scim_section(Igniter.t(), module(), String.t()) :: Igniter.t()

Adds a scim do ... end block with the given body to the resource if one isn't already declared. Idempotent — re-running won't duplicate the contents.

Uses Spark.Igniter.update_dsl/5 to handle section creation: if scim do ... end doesn't exist, Spark adds an empty one and walks inside it; we then drop our parsed body AST in. If it already exists, the existence check up front short-circuits, so we don't risk appending duplicates.

ensure_scim_bypass(igniter, resource)

@spec ensure_scim_bypass(Igniter.t(), module()) :: Igniter.t()

Adds the AshScim.Checks.AshScimInteraction bypass policy to the resource. Idempotent — re-running won't duplicate the bypass.

has_scim_section?(igniter, resource)

@spec has_scim_section?(Igniter.t(), module()) :: {Igniter.t(), boolean()}

Returns {igniter, true} if the resource already declares a scim DSL block, {igniter, false} otherwise. Used to make the installer idempotent.