Skip to content

Commit

Permalink
Merge pull request #535 from dylan-hoefsloot/feature/update_documenta…
Browse files Browse the repository at this point in the history
…tion_for_initial_transition

Add documentation for initial_transition feature
  • Loading branch information
stephenbinns committed Jan 12, 2024
2 parents 20f4fd8 + 8cb1fc3 commit 9bcf3fc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,23 @@ ActiveRecord adapter.

Statesman will fallback to memory unless you specify a transition_class when instantiating your state machine. This allows you to only persist transitions on certain state machines in your app.

### `initial_transition`

```ruby
def state_machine
@state_machine ||= OrderStateMachine.new(self, transition_class: OrderTransition,
association_name: :transitions,
initial_transition: true)
end
```

By default Statesman does not record a transition to the initial state of the state machine.

You can configure Statesman to record a transition to the initial state, this will allow you to:
- Keep an accurate record of the intial state even if configuration changes
- Keep a record of how long the state machine spent in the initial state
- Utilise a transition hook for the transition to the initial state

## Class methods

### `Machine.state`
Expand Down

0 comments on commit 9bcf3fc

Please sign in to comment.