Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zven21/aasm
The finite state machine implementations for Elixir.
https://github.com/zven21/aasm
ecto elixir elixir-lang hex state-machine
Last synced: about 2 months ago
JSON representation
The finite state machine implementations for Elixir.
- Host: GitHub
- URL: https://github.com/zven21/aasm
- Owner: zven21
- Created: 2019-06-10T06:14:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-11T05:44:40.000Z (over 5 years ago)
- Last Synced: 2024-10-29T08:40:02.971Z (2 months ago)
- Topics: ecto, elixir, elixir-lang, hex, state-machine
- Language: Elixir
- Size: 8.79 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AASM
> The finite state machine implementations for Elixir.
## Table of contents
* [Getting started](#getting-started)
* [Examples](#examples)
* [TODO](#todo)
* [Contributing](#contributing)
* [Make a pull request](#make-a-pull-request)
* [License](#license)
* [Credits](#credits)## Getting started
* The package can be installed by adding `aasm` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:aasm, "~> 0.2.0"}
]
end
```## Examples
```elixir
defmodule Dummy.Order do
@moduledoc """
Order model
"""use Ecto.Schema
import AASMaasm :state do
state(~w(state_created state_assigned state_finished state_closed)a)event(:handle_assigned, %{from: ~w(state_created)a, to: :state_assigned}, fn changeset ->
changeset
end)event(:handle_finished, %{from: ~w(state_assigned)a, to: :state_finished}, fn changeset ->
changeset
end)event(
:handle_closed,
%{from: ~w(state_created state_assigned state_finished)a, to: :state_closed},
fn changeset -> changeset end
)
endschema "orders" do
field(:state, :string)
end
end
```## TODO
* [ ] Support multi db column.
* [ ] Add before_event.
* [ ] Initial value## Contributing
Bug report or pull request are welcome.
## Make a pull request
1. Fork it
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 new Pull RequestPlease write unit test with your code if necessary.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
## Credits
* [aasm](https://github.com/aasm/aasm) - State machines for Ruby classes.
* [ecto_state_machine](https://github.com/asiniy/ecto_state_machine) - Other state machine for elixir.