Diffo.Provider.Calculations.InheritedPlace (Diffo v0.8.0)

Copy Markdown View Source

Backing calculation for inherited_place DSL declarations.

Walks the instance graph along the via: hop chain (the shared Diffo.Provider.Calculations.Traversal:forward/:reverse over assignment / relationship edges), then reads each reached instance's PlaceRef records at the declared source_role, optionally collapsing the result to one end. Injected automatically by TransformInheritedRefs — do not reference this module directly; use the inherited_place DSL entity instead.

via: reaches the instance that holds the ref; the source_role deref is a fixed terminal step, not a via: hop. Routing through a place — the ref graph — is a calculation concern, not a via: capability (see #227).

See Diffo.Provider.Extension.InheritedPlaceDeclaration for the DSL options.

Result shape

Without collapse, a list per input record — one or more Diffo.Provider.Place values per reached instance that carries a PlaceRef at source_role, or %Diffo.Unknown{} when an instance is reached but has no PlaceRef there. With collapse: :first | :last, a single value (or nil). When no instance is reached at all, [] (or nil when collapsing).

Reason vocabulary

PlaceRef is a universal indirection (no cross-world dispatch), so only one reason:

  • :role_not_declared — instance reached but its PlaceRef records carry no entry at source_role. :context is %{source_id: id, role: source_role}.

:world stamping

TransformInheritedRefs passes the consumer's resource as :world at compile time; each emitted %Diffo.Unknown{} stamps it.

Summary

Functions

describe(opts)

Callback implementation for Ash.Resource.Calculation.describe/1.

has_calculate?()

has_expression?()

Callback implementation for Ash.Resource.Calculation.has_expression?/0.

init(opts)

Callback implementation for Ash.Resource.Calculation.init/1.

strict_loads?()

Callback implementation for Ash.Resource.Calculation.strict_loads?/0.