Sha256: 32381f65e69227edafee461c266ef26240352b21c4d6ba36ca2cc8994bd29069

Contents?: true

Size: 443 Bytes

Versions: 4

Compression:

Stored size: 443 Bytes

Contents

require "microfsm"

# This example can be run with ruby -I lib/ ./examples/callbacks.rb

fsm = MicroFSM.new(:pending)
  .when(:confirm, pending: :confirmed) { puts "Confirmed" }
  .when(:ignore, pending: :ignored) { puts "Ignored" }
  .when(:reset, confirmed: :pending, ignored: :pending) {
  puts "Reset"
}

puts "Should print Confirmed, Reset and Ignored:"
fsm.trigger(:confirm)
fsm.trigger(:ignore)
fsm.trigger(:reset)
fsm.trigger(:ignore)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
microfsm-0.1.10 examples/callbacks.rb
microfsm-0.1.7 examples/callbacks.rb
microfsm-0.1.6 examples/callbacks.rb
microfsm-0.1.4 examples/callbacks.rb