Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/elcuervo/machina


https://github.com/elcuervo/machina

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# Machina

_a god introduced by means of a crane in ancient Greek and Roman drama to decide the final outcome_

![](https://theatricaleffectsandstaging.files.wordpress.com/2016/05/untitled1.png?w=390&h=326)

```ruby
fsm = Machina.new(:unconfirmed)

fsm.when[:welcome_email] = -> { send_welcome_email }
fsm.when[:enable_account] = -> (user) { user.enabled! }

fsm[:confirm] = {
:unconfirmed => [:welcome_email, :enable_account, :confirmed],
}

fsm.on[:confirm] = -> (user) { puts "Starting confirmation process for #{user.id}." }

fsm.state # => :unconfirmed
fsm.trigger!(:confirm, user)
fsm.state # => :confirmed
```