Sha256: faa1d50e705a1940b919ce8ab4ee01c1bf81da0914c01abdf79902cc4aa460a4
Contents?: true
Size: 641 Bytes
Versions: 5
Compression:
Stored size: 641 Bytes
Contents
require 'microfsm' # This example can be run with ruby -I lib/ ./examples/advanced.rb fsm = MicroFSM.new(:pending) proc = -> (event) { puts fsm.state.capitalize } fsm.when(:confirm, :pending => :confirmed, &proc) .when(:ignore, :pending => :ignored, &proc) .when(:reset, :confirmed => :pending, :ignored => :pending, &proc) puts "Should print Confirmed, Pending and Ignored:" fsm.trigger(:confirm) fsm.trigger(:ignore) fsm.trigger(:reset) fsm.trigger(:ignore) puts "Should print all states: confirmed, ignored, pending" puts fsm.states.join ", " puts "Should print all events: confirm, ignore, reset" puts fsm.events.join ", "
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
microfsm-0.1.3 | examples/advanced.rb |
microfsm-0.1.2 | examples/advanced.rb |
microfsm-0.1.1 | examples/advanced.rb |
microfsm-0.1.0 | examples/advanced.rb |
microfsm-0.0.1 | examples/advanced.rb |