Skip to content

Commit 7b4b6da

Browse files
committed
Uses Event.internal, adds doctest for Datamodel
1 parent 3e99aeb commit 7b4b6da

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

lib/statifier/actions/assign_action.ex

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,13 @@ defmodule Statifier.Actions.AssignAction do
9494

9595
{:error, reason} ->
9696
# Create error.execution event per SCXML specification
97-
error_event = %Event{
98-
name: "error.execution",
99-
data: %{
97+
error_event =
98+
Event.internal("error.execution", %{
10099
"reason" => inspect(reason),
101100
"type" => "assign.execution",
102101
"location" => assign_action.location,
103102
"expr" => assign_action.expr
104-
},
105-
origin: :internal
106-
}
103+
})
107104

108105
# Log the error and generate error.execution event per SCXML spec
109106
state_chart

lib/statifier/datamodel.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ defmodule Statifier.Datamodel do
102102
Set a value at a nested path in the datamodel.
103103
104104
Takes a datamodel, a list of path components (keys), and a value.
105-
Creates intermediate maps as needed for nested assignment.
105+
Does not create intermediate maps as needed for nested assignment.
106106
107107
## Examples
108108
109109
iex> datamodel = %{}
110110
iex> Statifier.Datamodel.put_in_path(datamodel, ["user", "name"], "John")
111-
{:ok, %{"user" => %{"name" => "John"}}}
111+
{:error, "Cannot assign to nested path: 'user' does not exist"}
112112
113113
iex> datamodel = %{"user" => %{"age" => 30}}
114114
iex> Statifier.Datamodel.put_in_path(datamodel, ["user", "name"], "Jane")

test/statifier/datamodel_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ defmodule Statifier.DatamodelTest do
1010
StateChart
1111
}
1212

13+
doctest Statifier.Datamodel
14+
1315
# Helper function to initialize a state chart from XML
1416
defp initialize_from_xml(xml) do
1517
{:ok, document, _warnings} = Statifier.parse(xml)

0 commit comments

Comments
 (0)