Sha256: be8f0704eb5015a54538ea1e327493c01fe3fd45b3ebf0f11673353331604185

Contents?: true

Size: 495 Bytes

Versions: 5

Compression:

Stored size: 495 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

5 entries across 5 versions & 1 rubygems

Version Path
microfsm-0.1.3 examples/callbacks.rb
microfsm-0.1.2 examples/callbacks.rb
microfsm-0.1.1 examples/callbacks.rb
microfsm-0.1.0 examples/callbacks.rb
microfsm-0.0.1 examples/callbacks.rb