module Transitions
Public Class Methods
draw(class_names, options = {})
click to toggle source
# File lib/graphviz_transitions.rb, line 9 def self.draw(class_names, options = {}) raise ArgumentError, "At least one class must be specified" unless class_names && class_names.split(',').any? event_options = options.extract!(:guards) class_names.split(',').each do |class_name| klass = class_name.constantize graph = Transitions::Graph.new(class_name, options) klass.get_state_machine.states.each do |state| state.draw(graph) end klass.get_state_machine.events.values.each do |event| event.draw(graph, event_options) end graph.output end end
Public Instance Methods
draw(graph)
click to toggle source
# File lib/graphviz_transitions.rb, line 33 def draw(graph) node = graph.add_nodes(self.name.to_s.humanize, shape: final? ? "doublecircle" : "box") graph.add_edge(graph.add_nodes("starting_state", shape: "point"), node) if initial? end
final?()
click to toggle source
# File lib/graphviz_transitions.rb, line 43 def final? false # !@klass.aasm.events.any? do |event| # event.transitions.any? do |transition| # transition.from == self.name # end # end end
initial?()
click to toggle source
# File lib/graphviz_transitions.rb, line 38 def initial? false # @klass.aasm.initial_state == self.name end