View Source Kalevala.Brain.Variable (kalevala v0.1.0)
Handle variable data in brain nodes
Replaces variables in the format of ${variable_name}
. Works with
a dot notation for nested variables.
Example:
The starting data
%{
channel_name: "rooms:${room_id}",
delay: 500,
text: "Welcome, ${character.name}!"
}
With the event data
%{
room_id: "room-id",
character: %{
name: "Elias"
}
}
Will replace to the following
%{
channel_name: "rooms:room-id",
delay: 500,
text: "Welcome, Elias!"
}
Link to this section Summary
Functions
Dereference a variable path from a map of data
Detect variables inside of the data
Replace action data variables with event data
Replace detected and dereferenced variables in the data
Walk the resulting data map to convert keys from atoms to strings
Scan the value for a variable, returning Variable
structs
Link to this section Functions
Dereference a variable path from a map of data
Detect variables inside of the data
Replace action data variables with event data
Replace detected and dereferenced variables in the data
Fails if any variables still contain an :error
value, they were
not able to be dereferenced.
Walk the resulting data map to convert keys from atoms to strings
This is useful when sending the resulting data struct to action params
Scan the value for a variable, returning Variable
structs