crystal-state_machine

forked from luislavena/crystal-state_machine
State Machine for Crystal

State Machine for Crystal

Build Status

Minimal State Machine, inspired by micromachine

Installation

Add it to Projectfile

deps do
  github "luislavena/crystal-state_machine"
end

Usage

require "state_machine"

machine = StateMachine.new(:pending)
machine.when(:confirm, { pending: :confirmed })
machine.when(:ignore,  { pending: :ignored })
machine.when(:reset,   { confirmed: :pending, ignored: :pending })

machine.on(:confirmed) do
  puts "Confirmed"
end

machine.trigger(:confirm)
machine.state              # => :confirmed

machine.trigger?(:ignore)  # => false

Development

TODO: Write instructions for development

Contributing

  1. Fork it ( https://github.com/luislavena/crystal-state_machine/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

crystal-state_machine

Owner
Statistic
  • 0
  • 0
  • 0
  • 1
  • 0
  • over 7 years ago
  • February 23, 2017
License

MIT License

Links
Synced at

Sat, 21 Dec 2024 16:41:59 GMT

Languages