Skip to content

Clarify purpose of initial_state option #561

@nilcolor

Description

@nilcolor

The README shows that I need to include the following in a model:

include Statesman::Adapters::ActiveRecordQueries[
  transition_class: OrderTransition,
  initial_state: :pending
]

And build the machine itself like:

class OrderStateMachine
  include Statesman::Machine

  state :pending, initial: true
  state :checking_out
end

At some point, I was thinking that initial_state option allow to set different initial state for a model that is using the same state machine. But it doesn't. This option also doesn't (right?) work if initial: true is not set. So, why this option is even added? This looks like a constant that can be taken from machine like initial_state: OrderStateMachine.initial_state during initialisation and cannot be changed by a user anyway.
Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions