Skip to content

Commit

Permalink
Limit keys from state and event meta hashes passed to draw methods (f…
Browse files Browse the repository at this point in the history
…ixes geekq#236)
  • Loading branch information
dchandekstark committed Nov 11, 2024
1 parent bf9e8fc commit 84f164c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/workflow/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def condition_applicable?(object, event_arguments)
end

def draw(graph, from_state)
graph.add_edges(from_state.name.to_s, transitions_to.to_s, meta.merge(:label => to_s))
edgesattrs = GraphViz::Constants::EDGESATTRS.keys.map(&:to_sym)

defaults = { label: to_s }

graph.add_edges(from_state.name.to_s, transitions_to.to_s, defaults.merge(meta.slice(*edgesattrs)))
end

def to_s
Expand Down
4 changes: 3 additions & 1 deletion lib/workflow/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def draw(graph)
:shape => 'ellipse'
}

node = graph.add_nodes(to_s, defaults.merge(meta))
nodesattrs = GraphViz::Constants::NODESATTRS.keys.map(&:to_sym)

node = graph.add_nodes(to_s, defaults.merge(meta.slice(*nodesattrs)))

# Add open arrow for initial state
# graph.add_edge(graph.add_node('starting_state', :shape => 'point'), node) if initial?
Expand Down

0 comments on commit 84f164c

Please sign in to comment.