Sha256: b2c7a3f114a5a99e3369ed24b00e1a360a6110ab4d75c8415d60bc5f11a3eb92
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
unless defined? $__fsm_dsl__ $__fsm_dsl__ = __FILE__ module FSM FSM::LIBDIR = File::dirname(File::expand_path(__FILE__)) + File::SEPARATOR unless defined? FSM::LIBDIR FSM::INCDIR = File::dirname(FSM::LIBDIR) + File::SEPARATOR unless defined? FSM::INCDIR require INCDIR + 'fsm' class GenericDSL def initialize object @object = object end def method_missing m, *a, &b if @object.respond_to? m @object.send m, *a, &b else super end end def configure &b instance_eval &b end end class FSM class DSL < GenericDSL def states *a @object.add_state *a end alias_method 'state', 'states' def transition *a, &b @object.add_transition *a, &b end alias_method 'transitioning', 'transition' end end class Observer class DSL < GenericDSL end end class System class DSL < GenericDSL def fsm &b b ? fsm.configure(&b) : @object.fsm end def observer &b b ? observer.configure(&b) : @object.observer end def method_missing m, *a, &b if fsm.respond_to? m fsm.send m, *a, &b else super end end end end end # module FSM end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fsm-0.0.0 | lib/fsm-0.0.0/dsl.rb |