This repository has been archived by the owner. It is now read-only.

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
  • 9
  • 1
  • 0
  • 0
  • 0
  • over 7 years ago
  • June 26, 2015
License

MIT License

Links
Synced at

Thu, 21 Nov 2024 16:35:54 GMT

Languages