AshScenario.Scenario.Helpers (ash_scenario v0.6.0)
View SourceShared helper functions for resource creation, used by both Runner and StructBuilder.
Summary
Functions
Build a changeset for creating a resource with Ash.
Execute a custom creation function.
Find a referenced resource in the created resources map.
Get a create action for a resource, with fallback to any create action.
Infer the domain for a resource module.
Normalize prototype refs and merge overrides from multiple sources.
Get the related module for a relationship attribute.
Check if an attribute name corresponds to a relationship.
Resolve a single attribute value, handling relationship references.
Resolve all attributes, handling relationship references.
Track telemetry for a created resource.
Functions
Build a changeset for creating a resource with Ash.
Returns {:ok, changeset, tenant_value} where tenant_value may be nil
if the resource doesn't use attribute-based multitenancy.
Execute a custom creation function.
Find a referenced resource in the created resources map.
Get a create action for a resource, with fallback to any create action.
Infer the domain for a resource module.
Normalize prototype refs and merge overrides from multiple sources.
Supports:
- Per-ref tuple: {Module, :ref, %{attr => value}}
- Top-level opts: overrides: %{{Module, :ref} => %{...}}
- For a single prototype, a bare map is allowed: overrides: %{...}
Check if an attribute name corresponds to a relationship.
Resolve a single attribute value, handling relationship references.
For database mode: Resolves atom references to IDs from created resources. For struct mode: Keep atom references as-is (handled by caller).
Resolve all attributes, handling relationship references.
Track telemetry for a created resource.