examples/advanced.rb in microfsm-0.1.3 vs examples/advanced.rb in microfsm-0.1.4
- old
+ new
@@ -1,13 +1,13 @@
-require 'microfsm'
+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)
+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)