This repository has been archived by the owner. It is now read-only.
crystal-state_machine
State 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
- 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