crystal-state_machine
forked from luislavena/crystal-state_machineState Machine for Crystal
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
- Fork it ( https://github.com/luislavena/crystal-state_machine/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- luislavena(https://github.com/luislavena) Luis Lavena - creator, maintainer
Repository
crystal-state_machine
Owner
Statistic
- 0
- 0
- 0
- 1
- 0
- over 7 years ago
- February 23, 2017
License
MIT License
Links
Synced at
Fri, 22 Nov 2024 01:49:14 GMT
Languages