Sha256: 2cbeb6fc9a7a5d810cfd3cdf2f4a8da65fdbbcc1b67c21e469819458a6e1c9e5
Contents?: true
Size: 642 Bytes
Versions: 2
Compression:
Stored size: 642 Bytes
Contents
module Stateflow class State attr_accessor :name, :options def initialize(name, &options) @name = name @options = Hash.new instance_eval(&options) if block_given? end def enter(method = nil, &block) @options[:enter] = method.nil? ? block : method end def exit(method = nil, &block) @options[:exit] = method.nil? ? block : method end def execute_action(action, base) action = @options[action.to_sym] case action when Symbol, String base.send(action) when Proc action.call(base) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stateflow-0.5.0.beta | lib/stateflow/state.rb |
stateflow-0.4.2 | lib/stateflow/state.rb |