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
- almost 8 years ago
- June 26, 2015
License
MIT License
Links
Synced at
Sun, 22 Dec 2024 15:30:23 GMT
Languages