Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv authored Jan 12, 2024
1 parent a7745b0 commit 66862ff
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,21 @@ Machine.successors
```
## Class constants
Each machine's state will turn into a constant:
Adding a state to a state machine will automatically create a constant for the value, for example:
```ruby
Machine.state(:some_state, initial: true)
Machine.state(:another_state)
class OrderStateMachine
include Statesman::Machine
state :pending, initial: true
state :checking_out
state :cancelled
# Constants created as a side effect of adding state
transition from: PENDING, to: [CHECKING_OUT, CANCELLED]
end
Machine::SOME_STATE #=> "some_state"
Machine::ANOTHER_STATE # => "another_state"
OrderStateMachine::PENDING #=> "pending"
OrderStateMachine::CHECKING_OUT # => "checking_out"
```
## Instance methods
Expand Down

0 comments on commit 66862ff

Please sign in to comment.