DiffoExample.Access.CharacteristicChanges (DiffoExample v0.2.3)

Copy Markdown View Source

Shared changeset helpers for Access characteristic update actions.

Characteristics store nested value structs (units, bandwidth profiles) as flat attributes. These helpers map the nested argument shape onto those attributes.

Summary

Functions

Splits a %{downstream: d, upstream: u, units: units} bandwidth-profile argument into three attributes.

Splits a %{amount: a, unit: u} argument into two attributes.

Functions

set_bandwidth_profile(changeset, arg, downstream_attr, upstream_attr, units_attr)

Splits a %{downstream: d, upstream: u, units: units} bandwidth-profile argument into three attributes.

Returns the changeset unchanged when the argument is nil or not a map with all three keys.

set_unit(changeset, arg, amount_attr, unit_attr)

Splits a %{amount: a, unit: u} argument into two attributes.

Returns the changeset unchanged when the argument is nil or not a map with both keys.