Ash Resource Fragment which is the point of extension for typed TMF Characteristics.
BaseCharacteristic is the foundation for domain-specific Characteristic kinds.
Include it as a fragment on an Ash.Resource to get a typed characteristic node
in Neo4j with real Ash attributes — no Ash.Type.Dynamic required.
Diffo.Provider.Characteristic remains available as the generic dynamic option
(storing values via Diffo.Type.Value); it includes Characteristic.Extension so
the DSL verifier accepts it alongside typed resources.
Usage
defmodule MyApp.CircuitCharacteristic do
use Ash.Resource, fragments: [BaseCharacteristic], domain: MyApp.Domain
attributes do
attribute :bandwidth_mbps, :integer, public?: true
attribute :technology, :atom, public?: true
end
actions do
create :create do
accept [:name, :bandwidth_mbps, :technology]
argument :instance_id, :uuid
argument :feature_id, :uuid
end
update :update do
accept [:bandwidth_mbps, :technology]
end
end
calculations do
calculate :value, Diffo.Type.CharacteristicValue, Diffo.Provider.Calculations.CharacteristicValue do
public? true
end
end
preparations do
prepare build(load: [:value])
end
jason do
pick [:name, :value]
compact true
end
endDSL declaration
provider do
characteristics do
characteristic :circuit, MyApp.CircuitCharacteristic
end
endAt build time a CircuitCharacteristic node is created and connected to the
instance via an :HAS edge. The name attribute (e.g. :circuit) identifies
the characteristic's role on the instance.
Typed vs dynamic
| Style | DSL target | Neo4j node | Value storage |
|---|---|---|---|
| Typed | BaseCharacteristic-derived | per-type label (e.g. :CircuitCharacteristic) | direct Ash attributes |
| Dynamic | Diffo.Provider.Characteristic | :Characteristic | Diffo.Type.Value dynamic |