Sha256: 77ce9414ca704e3524c8d6927f132730590cc698b6980c51a59806187c8b1ed1
Contents?: true
Size: 770 Bytes
Versions: 6
Compression:
Stored size: 770 Bytes
Contents
module Stateflow class Machine attr_accessor :states, :initial_state, :events def initialize(&machine) @states, @events = Hash.new, Hash.new instance_eval(&machine) end def state_column(name = nil) @state_column ||= name.nil? ? :state : name end private def initial(name) @initial_state_name = name end def state(*names, &options) names.each do |name| state = Stateflow::State.new(name, &options) @initial_state = state if @states.empty? || @initial_state_name == name @states[name.to_sym] = state end end def event(name, &transitions) event = Stateflow::Event.new(name, &transitions) @events[name.to_sym] = event end end end
Version data entries
6 entries across 6 versions & 1 rubygems