aasm

The finite state machine implementations for Elixir.

Latest version: 0.2.0 registry icon
Maintenance score
0
Safety score
0
Popularity score
0
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.2.0 0 0 0 0 0
0.1.0 0 0 0 0 0

Stability
Latest release:

0.2.0 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



AASM

The finite state machine implementations for Elixir.

Table of contents

Getting started

  • The package can be installed by adding aasm to your list of dependencies in mix.exs:
def deps do
  [
    {:aasm, "~> 0.2.0"}
  ]
end

Examples

defmodule Dummy.Order do
  @moduledoc """
  Order model
  """

  use Ecto.Schema
  import AASM

  aasm :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
    )
  end

  schema "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 Request

Please write unit test with your code if necessary.

License

The gem is available as open source under the terms of the MIT License.

Credits