Sha256: a0d8d1e57cbad980ef4c40f21432d5d10bb7f9d2484cecd5d710feea644c3a28
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module Workflow class State attr_accessor :name, :value, :events, :meta, :on_entry, :on_exit attr_reader :spec def initialize(name, value, spec, meta = {}) @name, @value, @spec, @events, @meta = name, value, spec, EventCollection.new, meta end def draw(graph) defaults = { :label => to_s, :width => '1', :height => '1', :shape => 'ellipse' } node = graph.add_nodes(to_s, defaults) # Add open arrow for initial state # graph.add_edge(graph.add_node('starting_state', :shape => 'point'), node) if initial? node end if RUBY_VERSION >= '1.9' include Comparable def <=>(other_state) states = spec.states.keys raise ArgumentError, "state `#{other_state}' does not exist" unless states.include?(other_state.to_sym) states.index(self.to_sym) <=> states.index(other_state.to_sym) end end def to_s "#{name}" end def to_sym name.to_sym end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
workflow-orchestrator-1.3.0 | lib/workflow/state.rb |